source: 3DVCSoftware/branches/HTM-15.1-dev0/source/Lib/TLibEncoder/SEIwrite.cpp

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

Integrated general SEI changes and following SEIs:

  • Multiview view position SEI
  • Multiview acquisition information SEI
  • Multiview scene information SEI
  • Inter-layer constrained tile sets SEI
  • Property svn:eol-style set to native
File size: 54.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-2015, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#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_SAMPLING_FILTER_HINT:
109    xWriteSEIChromaSamplingFilterHint(*static_cast<const SEIChromaSamplingFilterHint*>(&sei)/*, sps*/);
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::MASTERING_DISPLAY_COLOUR_VOLUME:
121    xWriteSEIMasteringDisplayColourVolume(*static_cast<const SEIMasteringDisplayColourVolume*>(&sei));
122    break;
123#if NH_MV
124#if !NH_MV_SEI
125   case SEI::SUB_BITSTREAM_PROPERTY:
126   xWriteSEISubBitstreamProperty(*static_cast<const SEISubBitstreamProperty*>(&sei));
127   break;
128#endif
129#endif
130#if NH_MV_SEI
131#if NH_MV_SEI_TBD
132   case SEI::LAYERS_NOT_PRESENT:
133     xWriteSEILayersNotPresent(*static_cast<const SEILayersNotPresent*>(&sei));
134     break; 
135#endif
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#if NH_MV_SEI_TBD
151   case SEI::ALPHA_CHANNEL_INFO:
152     xWriteSEIAlphaChannelInfo(*static_cast<const SEIAlphaChannelInfo*>(&sei));
153     break; 
154   case SEI::OVERLAY_INFO:
155     xWriteSEIOverlayInfo(*static_cast<const SEIOverlayInfo*>(&sei));
156     break; 
157#endif
158   case SEI::TEMPORAL_MV_PREDICTION_CONSTRAINTS:
159     xWriteSEITemporalMvPredictionConstraints(*static_cast<const SEITemporalMvPredictionConstraints*>(&sei));
160     break; 
161#if NH_MV_SEI_TBD
162   case SEI::FRAME_FIELD_INFO:
163     xWriteSEIFrameFieldInfo(*static_cast<const SEIFrameFieldInfo*>(&sei));
164     break; 
165   case SEI::THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO:
166     xWriteSEIThreeDimensionalReferenceDisplaysInfo(*static_cast<const SEIThreeDimensionalReferenceDisplaysInfo*>(&sei));
167     break; 
168   case SEI::DEPTH_REPRESENTATION_INFO:
169     xWriteSEIDepthRepresentationInfo(*static_cast<const SEIDepthRepresentationInfo*>(&sei));
170     break; 
171#endif
172   case SEI::MULTIVIEW_SCENE_INFO:
173     xWriteSEIMultiviewSceneInfo(*static_cast<const SEIMultiviewSceneInfo*>(&sei));
174     break; 
175   case SEI::MULTIVIEW_ACQUISITION_INFO:
176     xWriteSEIMultiviewAcquisitionInfo(*static_cast<const SEIMultiviewAcquisitionInfo*>(&sei));
177     break; 
178
179   case SEI::MULTIVIEW_VIEW_POSITION:
180     xWriteSEIMultiviewViewPosition(*static_cast<const SEIMultiviewViewPosition*>(&sei));
181     break; 
182#if NH_MV_SEI_TBD
183   case SEI::ALTERNATIVE_DEPTH_INFO:
184     xWriteSEIAlternativeDepthInfo(*static_cast<const SEIAlternativeDepthInfo*>(&sei));
185     break; 
186#endif
187#endif
188
189
190  default:
191    assert(!"Unhandled SEI message");
192    break;
193  }
194  xWriteByteAlign();
195}
196
197/**
198 * marshal all SEI messages in provided list into one bitstream bs
199 */
200Void SEIWriter::writeSEImessages(TComBitIf& bs, const SEIMessages &seiList, const TComSPS *sps, Bool isNested)
201{
202#if ENC_DEC_TRACE
203  if (g_HLSTraceEnable)
204    xTraceSEIHeader();
205#endif
206
207  TComBitCounter bs_count;
208
209  for (SEIMessages::const_iterator sei=seiList.begin(); sei!=seiList.end(); sei++)
210  {
211    // calculate how large the payload data is
212    // TODO: this would be far nicer if it used vectored buffers
213    bs_count.resetBits();
214    setBitstream(&bs_count);
215
216#if ENC_DEC_TRACE
217    Bool traceEnable = g_HLSTraceEnable;
218    g_HLSTraceEnable = false;
219#endif
220    xWriteSEIpayloadData(bs_count, **sei, sps);
221#if ENC_DEC_TRACE
222    g_HLSTraceEnable = traceEnable;
223#endif
224    UInt payload_data_num_bits = bs_count.getNumberOfWrittenBits();
225    assert(0 == payload_data_num_bits % 8);
226
227    setBitstream(&bs);
228    UInt payloadType = (*sei)->payloadType();
229    for (; payloadType >= 0xff; payloadType -= 0xff)
230    {
231      WRITE_CODE(0xff, 8, "payload_type");
232    }
233    WRITE_CODE(payloadType, 8, "payload_type");
234
235    UInt payloadSize = payload_data_num_bits/8;
236    for (; payloadSize >= 0xff; payloadSize -= 0xff)
237    {
238      WRITE_CODE(0xff, 8, "payload_size");
239    }
240    WRITE_CODE(payloadSize, 8, "payload_size");
241
242    /* payloadData */
243#if ENC_DEC_TRACE
244    if (g_HLSTraceEnable)
245      xTraceSEIMessageType((*sei)->payloadType());
246#endif
247
248    xWriteSEIpayloadData(bs, **sei, sps);
249  }
250  if (!isNested)
251  {
252    xWriteRbspTrailingBits();
253  }
254}
255
256/**
257 * marshal a user_data_unregistered SEI message sei, storing the marshalled
258 * representation in bitstream bs.
259 */
260Void SEIWriter::xWriteSEIuserDataUnregistered(const SEIuserDataUnregistered &sei)
261{
262  for (UInt i = 0; i < ISO_IEC_11578_LEN; i++)
263  {
264    WRITE_CODE(sei.uuid_iso_iec_11578[i], 8 , "sei.uuid_iso_iec_11578[i]");
265  }
266
267  for (UInt i = 0; i < sei.userDataLength; i++)
268  {
269    WRITE_CODE(sei.userData[i], 8 , "user_data");
270  }
271}
272
273/**
274 * marshal a decoded picture hash SEI message, storing the marshalled
275 * representation in bitstream bs.
276 */
277Void SEIWriter::xWriteSEIDecodedPictureHash(const SEIDecodedPictureHash& sei)
278{
279  const Char *traceString="\0";
280  switch (sei.method)
281  {
282    case SEIDecodedPictureHash::MD5: traceString="picture_md5"; break;
283    case SEIDecodedPictureHash::CRC: traceString="picture_crc"; break;
284    case SEIDecodedPictureHash::CHECKSUM: traceString="picture_checksum"; break;
285    default: assert(false); break;
286  }
287
288  if (traceString != 0) //use of this variable is needed to avoid a compiler error with G++ 4.6.1
289  {
290    WRITE_CODE(sei.method, 8, "hash_type");
291    for(UInt i=0; i<UInt(sei.m_pictureHash.hash.size()); i++)
292    {
293      WRITE_CODE(sei.m_pictureHash.hash[i], 8, traceString);
294    }
295  }
296}
297
298Void SEIWriter::xWriteSEIActiveParameterSets(const SEIActiveParameterSets& sei)
299{
300  WRITE_CODE(sei.activeVPSId,     4,         "active_video_parameter_set_id");
301  WRITE_FLAG(sei.m_selfContainedCvsFlag,     "self_contained_cvs_flag");
302  WRITE_FLAG(sei.m_noParameterSetUpdateFlag, "no_parameter_set_update_flag");
303  WRITE_UVLC(sei.numSpsIdsMinus1,            "num_sps_ids_minus1");
304
305  assert (sei.activeSeqParameterSetId.size() == (sei.numSpsIdsMinus1 + 1));
306
307  for (Int i = 0; i < sei.activeSeqParameterSetId.size(); i++)
308  {
309    WRITE_UVLC(sei.activeSeqParameterSetId[i], "active_seq_parameter_set_id"); 
310  }
311}
312
313Void SEIWriter::xWriteSEIDecodingUnitInfo(const SEIDecodingUnitInfo& sei, const TComSPS *sps)
314{
315  const TComVUI *vui = sps->getVuiParameters();
316  WRITE_UVLC(sei.m_decodingUnitIdx, "decoding_unit_idx");
317  if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag())
318  {
319    WRITE_CODE( sei.m_duSptCpbRemovalDelay, (vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1), "du_spt_cpb_removal_delay_increment");
320  }
321  WRITE_FLAG( sei.m_dpbOutputDuDelayPresentFlag, "dpb_output_du_delay_present_flag");
322  if(sei.m_dpbOutputDuDelayPresentFlag)
323  {
324    WRITE_CODE(sei.m_picSptDpbOutputDuDelay, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, "pic_spt_dpb_output_du_delay");
325  }
326}
327
328Void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei, const TComSPS *sps)
329{
330  Int i, nalOrVcl;
331  const TComVUI *vui = sps->getVuiParameters();
332  const TComHRD *hrd = vui->getHrdParameters();
333
334  WRITE_UVLC( sei.m_bpSeqParameterSetId, "bp_seq_parameter_set_id" );
335  if( !hrd->getSubPicCpbParamsPresentFlag() )
336  {
337    WRITE_FLAG( sei.m_rapCpbParamsPresentFlag, "irap_cpb_params_present_flag" );
338  }
339  if( sei.m_rapCpbParamsPresentFlag )
340  {
341    WRITE_CODE( sei.m_cpbDelayOffset, hrd->getCpbRemovalDelayLengthMinus1() + 1, "cpb_delay_offset" );
342    WRITE_CODE( sei.m_dpbDelayOffset, hrd->getDpbOutputDelayLengthMinus1()  + 1, "dpb_delay_offset" );
343  }
344  WRITE_FLAG( sei.m_concatenationFlag, "concatenation_flag");
345  WRITE_CODE( sei.m_auCpbRemovalDelayDelta - 1, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), "au_cpb_removal_delay_delta_minus1" );
346  for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
347  {
348    if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) ||
349        ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) )
350    {
351      for( i = 0; i < ( hrd->getCpbCntMinus1( 0 ) + 1 ); i ++ )
352      {
353        WRITE_CODE( sei.m_initialCpbRemovalDelay[i][nalOrVcl],( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ) ,           "initial_cpb_removal_delay" );
354        WRITE_CODE( sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl],( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ),      "initial_cpb_removal_delay_offset" );
355        if( hrd->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag )
356        {
357          WRITE_CODE( sei.m_initialAltCpbRemovalDelay[i][nalOrVcl], ( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ) ,     "initial_alt_cpb_removal_delay" );
358          WRITE_CODE( sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl], ( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ),"initial_alt_cpb_removal_delay_offset" );
359        }
360      }
361    }
362  }
363}
364Void SEIWriter::xWriteSEIPictureTiming(const SEIPictureTiming& sei, const TComSPS *sps)
365{
366  Int i;
367  const TComVUI *vui = sps->getVuiParameters();
368  const TComHRD *hrd = vui->getHrdParameters();
369
370  if( vui->getFrameFieldInfoPresentFlag() )
371  {
372    WRITE_CODE( sei.m_picStruct, 4,              "pic_struct" );
373    WRITE_CODE( sei.m_sourceScanType, 2,         "source_scan_type" );
374    WRITE_FLAG( sei.m_duplicateFlag ? 1 : 0,     "duplicate_flag" );
375  }
376
377  if( hrd->getCpbDpbDelaysPresentFlag() )
378  {
379    WRITE_CODE( sei.m_auCpbRemovalDelay - 1, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ),                                         "au_cpb_removal_delay_minus1" );
380    WRITE_CODE( sei.m_picDpbOutputDelay, ( hrd->getDpbOutputDelayLengthMinus1() + 1 ),                                          "pic_dpb_output_delay" );
381    if(hrd->getSubPicCpbParamsPresentFlag())
382    {
383      WRITE_CODE(sei.m_picDpbOutputDuDelay, hrd->getDpbOutputDelayDuLengthMinus1()+1, "pic_dpb_output_du_delay" );
384    }
385    if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() )
386    {
387      WRITE_UVLC( sei.m_numDecodingUnitsMinus1,     "num_decoding_units_minus1" );
388      WRITE_FLAG( sei.m_duCommonCpbRemovalDelayFlag, "du_common_cpb_removal_delay_flag" );
389      if( sei.m_duCommonCpbRemovalDelayFlag )
390      {
391        WRITE_CODE( sei.m_duCommonCpbRemovalDelayMinus1, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ),                       "du_common_cpb_removal_delay_minus1" );
392      }
393      for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ )
394      {
395        WRITE_UVLC( sei.m_numNalusInDuMinus1[ i ],  "num_nalus_in_du_minus1");
396        if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) )
397        {
398          WRITE_CODE( sei.m_duCpbRemovalDelayMinus1[ i ], ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ),                        "du_cpb_removal_delay_minus1" );
399        }
400      }
401    }
402  }
403}
404Void SEIWriter::xWriteSEIRecoveryPoint(const SEIRecoveryPoint& sei)
405{
406  WRITE_SVLC( sei.m_recoveryPocCnt,    "recovery_poc_cnt"    );
407  WRITE_FLAG( sei.m_exactMatchingFlag, "exact_matching_flag" );
408  WRITE_FLAG( sei.m_brokenLinkFlag,    "broken_link_flag"    );
409}
410Void SEIWriter::xWriteSEIFramePacking(const SEIFramePacking& sei)
411{
412  WRITE_UVLC( sei.m_arrangementId,                  "frame_packing_arrangement_id" );
413  WRITE_FLAG( sei.m_arrangementCancelFlag,          "frame_packing_arrangement_cancel_flag" );
414
415  if( sei.m_arrangementCancelFlag == 0 )
416  {
417    WRITE_CODE( sei.m_arrangementType, 7,           "frame_packing_arrangement_type" );
418
419    WRITE_FLAG( sei.m_quincunxSamplingFlag,         "quincunx_sampling_flag" );
420    WRITE_CODE( sei.m_contentInterpretationType, 6, "content_interpretation_type" );
421    WRITE_FLAG( sei.m_spatialFlippingFlag,          "spatial_flipping_flag" );
422    WRITE_FLAG( sei.m_frame0FlippedFlag,            "frame0_flipped_flag" );
423    WRITE_FLAG( sei.m_fieldViewsFlag,               "field_views_flag" );
424    WRITE_FLAG( sei.m_currentFrameIsFrame0Flag,     "current_frame_is_frame0_flag" );
425
426    WRITE_FLAG( sei.m_frame0SelfContainedFlag,      "frame0_self_contained_flag" );
427    WRITE_FLAG( sei.m_frame1SelfContainedFlag,      "frame1_self_contained_flag" );
428
429    if(sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5)
430    {
431      WRITE_CODE( sei.m_frame0GridPositionX, 4,     "frame0_grid_position_x" );
432      WRITE_CODE( sei.m_frame0GridPositionY, 4,     "frame0_grid_position_y" );
433      WRITE_CODE( sei.m_frame1GridPositionX, 4,     "frame1_grid_position_x" );
434      WRITE_CODE( sei.m_frame1GridPositionY, 4,     "frame1_grid_position_y" );
435    }
436
437    WRITE_CODE( sei.m_arrangementReservedByte, 8,   "frame_packing_arrangement_reserved_byte" );
438    WRITE_FLAG( sei.m_arrangementPersistenceFlag,   "frame_packing_arrangement_persistence_flag" );
439  }
440
441  WRITE_FLAG( sei.m_upsampledAspectRatio,           "upsampled_aspect_ratio" );
442}
443
444Void SEIWriter::xWriteSEISegmentedRectFramePacking(const SEISegmentedRectFramePacking& sei)
445{
446  WRITE_FLAG( sei.m_arrangementCancelFlag,          "segmented_rect_frame_packing_arrangement_cancel_flag" );
447  if( sei.m_arrangementCancelFlag == 0 ) 
448  {
449    WRITE_CODE( sei.m_contentInterpretationType, 2, "segmented_rect_content_interpretation_type" );
450    WRITE_FLAG( sei.m_arrangementPersistenceFlag,   "segmented_rect_frame_packing_arrangement_persistence" );
451  }
452}
453
454Void SEIWriter::xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei)
455{
456  Int i;
457  WRITE_UVLC( sei.m_toneMapId,                    "tone_map_id" );
458  WRITE_FLAG( sei.m_toneMapCancelFlag,            "tone_map_cancel_flag" );
459  if( !sei.m_toneMapCancelFlag )
460  {
461    WRITE_FLAG( sei.m_toneMapPersistenceFlag,     "tone_map_persistence_flag" );
462    WRITE_CODE( sei.m_codedDataBitDepth,    8,    "coded_data_bit_depth" );
463    WRITE_CODE( sei.m_targetBitDepth,       8,    "target_bit_depth" );
464    WRITE_UVLC( sei.m_modelId,                    "model_id" );
465    switch(sei.m_modelId)
466    {
467    case 0:
468      {
469        WRITE_CODE( sei.m_minValue,  32,        "min_value" );
470        WRITE_CODE( sei.m_maxValue, 32,         "max_value" );
471        break;
472      }
473    case 1:
474      {
475        WRITE_CODE( sei.m_sigmoidMidpoint, 32,  "sigmoid_midpoint" );
476        WRITE_CODE( sei.m_sigmoidWidth,    32,  "sigmoid_width"    );
477        break;
478      }
479    case 2:
480      {
481        UInt num = 1u << sei.m_targetBitDepth;
482        for(i = 0; i < num; i++)
483        {
484          WRITE_CODE( sei.m_startOfCodedInterval[i], (( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3,  "start_of_coded_interval" );
485        }
486        break;
487      }
488    case 3:
489      {
490        WRITE_CODE( sei.m_numPivots, 16,          "num_pivots" );
491        for(i = 0; i < sei.m_numPivots; i++ )
492        {
493          WRITE_CODE( sei.m_codedPivotValue[i], (( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3,       "coded_pivot_value" );
494          WRITE_CODE( sei.m_targetPivotValue[i], (( sei.m_targetBitDepth + 7 ) >> 3 ) << 3,         "target_pivot_value");
495        }
496        break;
497      }
498    case 4:
499      {
500        WRITE_CODE( sei.m_cameraIsoSpeedIdc,    8,    "camera_iso_speed_idc" );
501        if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO
502        {
503          WRITE_CODE( sei.m_cameraIsoSpeedValue,    32,    "camera_iso_speed_value" );
504        }
505        WRITE_CODE( sei.m_exposureIndexIdc,     8,    "exposure_index_idc" );
506        if( sei.m_exposureIndexIdc == 255) //Extended_ISO
507        {
508          WRITE_CODE( sei.m_exposureIndexValue,     32,    "exposure_index_value" );
509        }
510        WRITE_FLAG( sei.m_exposureCompensationValueSignFlag,           "exposure_compensation_value_sign_flag" );
511        WRITE_CODE( sei.m_exposureCompensationValueNumerator,     16,  "exposure_compensation_value_numerator" );
512        WRITE_CODE( sei.m_exposureCompensationValueDenomIdc,      16,  "exposure_compensation_value_denom_idc" );
513        WRITE_CODE( sei.m_refScreenLuminanceWhite,                32,  "ref_screen_luminance_white" );
514        WRITE_CODE( sei.m_extendedRangeWhiteLevel,                32,  "extended_range_white_level" );
515        WRITE_CODE( sei.m_nominalBlackLevelLumaCodeValue,         16,  "nominal_black_level_luma_code_value" );
516        WRITE_CODE( sei.m_nominalWhiteLevelLumaCodeValue,         16,  "nominal_white_level_luma_code_value" );
517        WRITE_CODE( sei.m_extendedWhiteLevelLumaCodeValue,        16,  "extended_white_level_luma_code_value" );
518        break;
519      }
520    default:
521      {
522        assert(!"Undefined SEIToneMapModelId");
523        break;
524      }
525    }//switch m_modelId
526  }//if(!sei.m_toneMapCancelFlag)
527}
528
529Void SEIWriter::xWriteSEIDisplayOrientation(const SEIDisplayOrientation &sei)
530{
531  WRITE_FLAG( sei.cancelFlag,           "display_orientation_cancel_flag" );
532  if( !sei.cancelFlag )
533  {
534    WRITE_FLAG( sei.horFlip,                   "hor_flip" );
535    WRITE_FLAG( sei.verFlip,                   "ver_flip" );
536    WRITE_CODE( sei.anticlockwiseRotation, 16, "anticlockwise_rotation" );
537    WRITE_FLAG( sei.persistenceFlag,          "display_orientation_persistence_flag" );
538  }
539}
540
541Void SEIWriter::xWriteSEITemporalLevel0Index(const SEITemporalLevel0Index &sei)
542{
543  WRITE_CODE( sei.tl0Idx, 8 , "tl0_idx" );
544  WRITE_CODE( sei.rapIdx, 8 , "rap_idx" );
545}
546
547Void SEIWriter::xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei)
548{
549  WRITE_FLAG( sei.m_gdrForegroundFlag, "gdr_foreground_flag");
550}
551
552Void SEIWriter::xWriteSEINoDisplay(const SEINoDisplay& /*sei*/)
553{
554}
555
556Void SEIWriter::xWriteSEISOPDescription(const SEISOPDescription& sei)
557{
558  WRITE_UVLC( sei.m_sopSeqParameterSetId,           "sop_seq_parameter_set_id"               );
559  WRITE_UVLC( sei.m_numPicsInSopMinus1,             "num_pics_in_sop_minus1"               );
560  for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++)
561  {
562    WRITE_CODE( sei.m_sopDescVclNaluType[i], 6, "sop_desc_vcl_nalu_type" );
563    WRITE_CODE( sei.m_sopDescTemporalId[i],  3, "sop_desc_temporal_id" );
564    if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP)
565    {
566      WRITE_UVLC( sei.m_sopDescStRpsIdx[i],           "sop_desc_st_rps_idx"               );
567    }
568    if (i > 0)
569    {
570      WRITE_SVLC( sei.m_sopDescPocDelta[i],           "sop_desc_poc_delta"               );
571    }
572  }
573}
574
575Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, const TComSPS *sps)
576{
577  WRITE_FLAG( sei.m_bitStreamSubsetFlag,             "bitstream_subset_flag"         );
578  WRITE_FLAG( sei.m_nestingOpFlag,                   "nesting_op_flag      "         );
579  if (sei.m_nestingOpFlag)
580  {
581    WRITE_FLAG( sei.m_defaultOpFlag,                 "default_op_flag"               );
582    WRITE_UVLC( sei.m_nestingNumOpsMinus1,           "nesting_num_ops_minus1"        );
583    for (UInt i = (sei.m_defaultOpFlag ? 1 : 0); i <= sei.m_nestingNumOpsMinus1; i++)
584    {
585      WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3,  "nesting_max_temporal_id_plus1" );
586      WRITE_UVLC( sei.m_nestingOpIdx[i],                  "nesting_op_idx"                );
587    }
588  }
589  else
590  {
591    WRITE_FLAG( sei.m_allLayersFlag,                      "all_layers_flag"               );
592    if (!sei.m_allLayersFlag)
593    {
594      WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id_plus1" );
595      WRITE_UVLC( sei.m_nestingNumLayersMinus1,           "nesting_num_layers"                  );
596      for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++)
597      {
598        WRITE_CODE( sei.m_nestingLayerId[i], 6,           "nesting_layer_id"              );
599      }
600    }
601  }
602
603  // byte alignment
604  while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 )
605  {
606    WRITE_FLAG( 0, "nesting_zero_bit" );
607  }
608
609  // write nested SEI messages
610  writeSEImessages(bs, sei.m_nestedSEIs, sps, true);
611}
612
613Void SEIWriter::xWriteSEITempMotionConstrainedTileSets(const SEITempMotionConstrainedTileSets& sei)
614{
615  //UInt code;
616  WRITE_FLAG((sei.m_mc_all_tiles_exact_sample_value_match_flag ? 1 : 0), "mc_all_tiles_exact_sample_value_match_flag"); 
617  WRITE_FLAG((sei.m_each_tile_one_tile_set_flag                ? 1 : 0), "each_tile_one_tile_set_flag"               );
618
619  if(!sei.m_each_tile_one_tile_set_flag)
620  {
621    WRITE_FLAG((sei.m_limited_tile_set_display_flag ? 1 : 0), "limited_tile_set_display_flag");
622    WRITE_UVLC((sei.getNumberOfTileSets() - 1),               "num_sets_in_message_minus1"   );
623
624    if(sei.getNumberOfTileSets() > 0)
625    {
626      for(Int i = 0; i < sei.getNumberOfTileSets(); i++)
627      {
628        WRITE_UVLC(sei.tileSetData(i).m_mcts_id, "mcts_id");
629
630        if(sei.m_limited_tile_set_display_flag)
631        { 
632          WRITE_FLAG((sei.tileSetData(i).m_display_tile_set_flag ? 1 : 0), "display_tile_set_flag"); 
633        }
634
635        WRITE_UVLC((sei.tileSetData(i).getNumberOfTileRects() - 1), "num_tile_rects_in_set_minus1"); 
636       
637        for(Int j = 0; j < sei.tileSetData(i).getNumberOfTileRects(); j++)
638        {
639          WRITE_UVLC(sei.tileSetData(i).topLeftTileIndex    (j), "top_left_tile_index"); 
640          WRITE_UVLC(sei.tileSetData(i).bottomRightTileIndex(j), "bottom_right_tile_index"); 
641        }
642
643        if(!sei.m_mc_all_tiles_exact_sample_value_match_flag)
644        {
645          WRITE_FLAG((sei.tileSetData(i).m_exact_sample_value_match_flag ? 1 : 0), "exact_sample_value_match_flag"); 
646        }
647
648        WRITE_FLAG((sei.tileSetData(i).m_mcts_tier_level_idc_present_flag ? 1 : 0), "mcts_tier_level_idc_present_flag");
649
650        if(sei.tileSetData(i).m_mcts_tier_level_idc_present_flag)
651        {
652          WRITE_FLAG((sei.tileSetData(i).m_mcts_tier_flag ? 1 : 0), "mcts_tier_flag");
653          WRITE_CODE( sei.tileSetData(i).m_mcts_level_idc, 8,       "mcts_level_idc"); 
654        }
655      }
656    }
657  }
658  else
659  {
660    WRITE_FLAG((sei.m_max_mcs_tier_level_idc_present_flag ? 1 : 0), "max_mcs_tier_level_idc_present_flag");
661
662    if(sei.m_max_mcs_tier_level_idc_present_flag)
663    {
664      WRITE_FLAG((sei.m_max_mcts_tier_flag ? 1 : 0), "max_mcts_tier_flag"); 
665      WRITE_CODE( sei.m_max_mcts_level_idc, 8,       "max_mcts_level_idc"); 
666    }
667  }
668}
669
670Void SEIWriter::xWriteSEITimeCode(const SEITimeCode& sei)
671{
672  WRITE_CODE(sei.numClockTs, 2, "num_clock_ts");
673  for(Int i = 0; i < sei.numClockTs; i++)
674  {
675    const TComSEITimeSet &currentTimeSet = sei.timeSetArray[i];
676    WRITE_FLAG(currentTimeSet.clockTimeStampFlag, "clock_time_stamp_flag");
677    if(currentTimeSet.clockTimeStampFlag)
678    {
679      WRITE_FLAG(currentTimeSet.numUnitFieldBasedFlag, "units_field_based_flag");
680      WRITE_CODE(currentTimeSet.countingType, 5, "counting_type");
681      WRITE_FLAG(currentTimeSet.fullTimeStampFlag, "full_timestamp_flag");
682      WRITE_FLAG(currentTimeSet.discontinuityFlag, "discontinuity_flag");
683      WRITE_FLAG(currentTimeSet.cntDroppedFlag, "cnt_dropped_flag");
684      WRITE_CODE(currentTimeSet.numberOfFrames, 9, "n_frames");
685      if(currentTimeSet.fullTimeStampFlag)
686      {
687        WRITE_CODE(currentTimeSet.secondsValue, 6, "seconds_value");
688        WRITE_CODE(currentTimeSet.minutesValue, 6, "minutes_value");
689        WRITE_CODE(currentTimeSet.hoursValue, 5, "hours_value");
690      }
691      else
692      {
693        WRITE_FLAG(currentTimeSet.secondsFlag, "seconds_flag");
694        if(currentTimeSet.secondsFlag)
695        {
696          WRITE_CODE(currentTimeSet.secondsValue, 6, "seconds_value");
697          WRITE_FLAG(currentTimeSet.minutesFlag, "minutes_flag");
698          if(currentTimeSet.minutesFlag)
699          {
700            WRITE_CODE(currentTimeSet.minutesValue, 6, "minutes_value");
701            WRITE_FLAG(currentTimeSet.hoursFlag, "hours_flag");
702            if(currentTimeSet.hoursFlag)
703            {
704              WRITE_CODE(currentTimeSet.hoursValue, 5, "hours_value");
705            }
706          }
707        }
708      }
709      WRITE_CODE(currentTimeSet.timeOffsetLength, 5, "time_offset_length");
710      if(currentTimeSet.timeOffsetLength > 0)
711      {
712        if(currentTimeSet.timeOffsetValue >= 0)
713        {
714          WRITE_CODE((UInt)currentTimeSet.timeOffsetValue, currentTimeSet.timeOffsetLength, "time_offset_value");
715        }
716        else
717        {
718          //  Two's complement conversion
719          UInt offsetValue = ~(currentTimeSet.timeOffsetValue) + 1;
720          offsetValue |= (1 << (currentTimeSet.timeOffsetLength-1));
721          WRITE_CODE(offsetValue, currentTimeSet.timeOffsetLength, "time_offset_value");
722        }
723      }
724    }
725  }
726}
727
728Void SEIWriter::xWriteSEIChromaSamplingFilterHint(const SEIChromaSamplingFilterHint &sei/*, TComSPS* sps*/)
729{
730  WRITE_CODE(sei.m_verChromaFilterIdc, 8, "ver_chroma_filter_idc");
731  WRITE_CODE(sei.m_horChromaFilterIdc, 8, "hor_chroma_filter_idc");
732  WRITE_FLAG(sei.m_verFilteringProcessFlag, "ver_filtering_process_flag");
733  if(sei.m_verChromaFilterIdc == 1 || sei.m_horChromaFilterIdc == 1)
734  {
735    writeUserDefinedCoefficients(sei);
736  }
737}
738
739// write hardcoded chroma filter coefficients in the SEI messages
740Void SEIWriter::writeUserDefinedCoefficients(const SEIChromaSamplingFilterHint &sei)
741{
742  Int const iNumVerticalFilters = 3;
743  Int verticalTapLength_minus1[iNumVerticalFilters] = {5,3,3};
744  Int* userVerticalCoefficients[iNumVerticalFilters];
745  for(Int i = 0; i < iNumVerticalFilters; i ++)
746  {
747    userVerticalCoefficients[i] = (Int*)malloc( (verticalTapLength_minus1[i]+1) * sizeof(Int));
748  }
749  userVerticalCoefficients[0][0] = -3;
750  userVerticalCoefficients[0][1] = 13;
751  userVerticalCoefficients[0][2] = 31;
752  userVerticalCoefficients[0][3] = 23;
753  userVerticalCoefficients[0][4] = 3;
754  userVerticalCoefficients[0][5] = -3;
755
756  userVerticalCoefficients[1][0] = -1;
757  userVerticalCoefficients[1][1] = 25;
758  userVerticalCoefficients[1][2] = 247;
759  userVerticalCoefficients[1][3] = -15;
760
761  userVerticalCoefficients[2][0] = -20;
762  userVerticalCoefficients[2][1] = 186;
763  userVerticalCoefficients[2][2] = 100;
764  userVerticalCoefficients[2][3] = -10;
765 
766  Int const iNumHorizontalFilters = 1;
767  Int horizontalTapLength_minus1[iNumHorizontalFilters] = {3};
768  Int* userHorizontalCoefficients[iNumHorizontalFilters];
769  for(Int i = 0; i < iNumHorizontalFilters; i ++)
770  {
771    userHorizontalCoefficients[i] = (Int*)malloc( (horizontalTapLength_minus1[i]+1) * sizeof(Int));
772  }
773  userHorizontalCoefficients[0][0] = 1;
774  userHorizontalCoefficients[0][1] = 6;
775  userHorizontalCoefficients[0][2] = 1;
776
777  WRITE_UVLC(3, "target_format_idc");
778  if(sei.m_verChromaFilterIdc == 1)
779  {
780    WRITE_UVLC(iNumVerticalFilters, "num_vertical_filters");
781    if(iNumVerticalFilters > 0)
782    {
783      for(Int i = 0; i < iNumVerticalFilters; i ++)
784      {
785        WRITE_UVLC(verticalTapLength_minus1[i], "ver_tap_length_minus_1");
786        for(Int j = 0; j < verticalTapLength_minus1[i]; j ++)
787        {
788          WRITE_SVLC(userVerticalCoefficients[i][j], "ver_filter_coeff");
789        }
790      }
791    }
792  }
793  if(sei.m_horChromaFilterIdc == 1)
794  {
795    WRITE_UVLC(iNumHorizontalFilters, "num_horizontal_filters");
796    if(iNumHorizontalFilters > 0)
797    {
798      for(Int i = 0; i < iNumHorizontalFilters; i ++)
799      {
800        WRITE_UVLC(horizontalTapLength_minus1[i], "hor_tap_length_minus_1");
801        for(Int j = 0; j < horizontalTapLength_minus1[i]; j ++)
802        {
803          WRITE_SVLC(userHorizontalCoefficients[i][j], "hor_filter_coeff");
804        }
805      }
806    }
807  }
808}
809
810#if NH_MV
811#if !NH_MV_SEI
812Void SEIWriter::xWriteSEISubBitstreamProperty(const SEISubBitstreamProperty &sei)
813{
814  WRITE_CODE( sei.m_activeVpsId, 4, "active_vps_id" );
815  assert( sei.m_numAdditionalSubStreams >= 1 );
816  WRITE_UVLC( sei.m_numAdditionalSubStreams - 1, "num_additional_sub_streams_minus1" );
817
818  for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ )
819  {
820    WRITE_CODE( sei.m_subBitstreamMode[i],       2, "sub_bitstream_mode[i]"           );
821    WRITE_UVLC( sei.m_outputLayerSetIdxToVps[i],    "output_layer_set_idx_to_vps[i]"  );
822    WRITE_CODE( sei.m_highestSublayerId[i],      3, "highest_sub_layer_id[i]"         );
823    WRITE_CODE( sei.m_avgBitRate[i],            16, "avg_bit_rate[i]"                 );
824    WRITE_CODE( sei.m_maxBitRate[i],            16, "max_bit_rate[i]"                 );
825  }
826  xWriteByteAlign();
827}
828#endif
829#endif
830
831Void SEIWriter::xWriteSEIKneeFunctionInfo(const SEIKneeFunctionInfo &sei)
832{
833  WRITE_UVLC( sei.m_kneeId, "knee_function_id" );
834  WRITE_FLAG( sei.m_kneeCancelFlag, "knee_function_cancel_flag" ); 
835  if ( !sei.m_kneeCancelFlag )
836  {
837    WRITE_FLAG( sei.m_kneePersistenceFlag, "knee_function_persistence_flag" );
838    WRITE_CODE( (UInt)sei.m_kneeInputDrange , 32,  "input_d_range" );
839    WRITE_CODE( (UInt)sei.m_kneeInputDispLuminance, 32,  "input_disp_luminance" );
840    WRITE_CODE( (UInt)sei.m_kneeOutputDrange, 32,  "output_d_range" );
841    WRITE_CODE( (UInt)sei.m_kneeOutputDispLuminance, 32,  "output_disp_luminance" );
842    WRITE_UVLC( sei.m_kneeNumKneePointsMinus1, "num_knee_points_minus1" );
843    for(Int i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ )
844    {
845      WRITE_CODE( (UInt)sei.m_kneeInputKneePoint[i], 10,"input_knee_point" );
846      WRITE_CODE( (UInt)sei.m_kneeOutputKneePoint[i], 10, "output_knee_point" );
847    }
848  }
849}
850
851
852Void SEIWriter::xWriteSEIMasteringDisplayColourVolume(const SEIMasteringDisplayColourVolume& sei)
853{
854  WRITE_CODE( sei.values.primaries[0][0],  16,  "display_primaries_x[0]" );
855  WRITE_CODE( sei.values.primaries[0][1],  16,  "display_primaries_y[0]" );
856
857  WRITE_CODE( sei.values.primaries[1][0],  16,  "display_primaries_x[1]" );
858  WRITE_CODE( sei.values.primaries[1][1],  16,  "display_primaries_y[1]" );
859
860  WRITE_CODE( sei.values.primaries[2][0],  16,  "display_primaries_x[2]" );
861  WRITE_CODE( sei.values.primaries[2][1],  16,  "display_primaries_y[2]" );
862
863  WRITE_CODE( sei.values.whitePoint[0],    16,  "white_point_x" );
864  WRITE_CODE( sei.values.whitePoint[1],    16,  "white_point_y" );
865   
866  WRITE_CODE( sei.values.maxLuminance,     32,  "max_display_mastering_luminance" );
867  WRITE_CODE( sei.values.minLuminance,     32,  "min_display_mastering_luminance" );
868}
869
870
871Void SEIWriter::xWriteByteAlign()
872{
873  if( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0)
874  {
875    WRITE_FLAG( 1, "payload_bit_equal_to_one" );
876    while( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 )
877    {
878      WRITE_FLAG( 0, "payload_bit_equal_to_zero" );
879    }
880  }
881}
882
883#if NH_MV_SEI_TBD
884Void SEIWriter::xWriteSEILayersNotPresent( const SEILayersNotPresent& sei)
885{
886  WRITE_CODE( sei.m_lnpSeiActiveVpsId, 4, "lnp_sei_active_vps_id" );
887  for( Int i = 0; i  <=  MaxLayersMinus1; i++ )
888  {
889    WRITE_FLAG( ( sei.m_layerNotPresentFlag[i] ? 1 : 0 ), "layer_not_present_flag" );
890  }
891};
892#endif
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#if NH_MV_SEI_TBD
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, getAlphaTransparentValueLen ), "alpha_transparent_value" );
988    WRITE_CODE( sei.m_alphaOpaqueValue, getAlphaOpaqueValueLen ), "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  <=  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], getOverlayElementLabelMinLen ), "overlay_element_label_min" );
1029          WRITE_CODE( sei.m_overlayElementLabelMax[i][j], getOverlayElementLabelMaxLen ), "overlay_element_label_max" );
1030        }
1031      }
1032    }
1033    while( !ByteaLigned(() ) );
1034    {
1035      WRITE_CODE( sei.m_overlayZeroBit, *equalto0*/f1, "overlay_zero_bit" );
1036    }
1037    for( Int i = 0; i  <=  NumOverlaysMinus1( ); i++ )
1038    {
1039      if( sei.m_languageOverlayPresentFlag( i ) )
1040      {
1041        WRITE_CODE( sei.m_overlayLanguage[i], tv, "overlay_language" );
1042      }
1043      WRITE_CODE( sei.m_overlayName[i], tv, "overlay_name" );
1044      if( sei.m_overlayLabelPresentFlag( i ) )
1045      {
1046        for( Int j = 0; j  <=  sei.m_numOverlayElementsMinus1( i ); j++ )
1047        {
1048          WRITE_CODE( sei.m_overlayElementName[i][j], tv, "overlay_element_name" );
1049        }
1050      }
1051    }
1052    WRITE_FLAG( ( sei.m_overlayInfoPersistenceFlag ? 1 : 0 ), "overlay_info_persistence_flag" );
1053  }
1054};
1055#endif
1056
1057Void SEIWriter::xWriteSEITemporalMvPredictionConstraints( const SEITemporalMvPredictionConstraints& sei)
1058{
1059  WRITE_FLAG( ( sei.m_prevPicsNotUsedFlag    ? 1 : 0 ), "prev_pics_not_used_flag"     );
1060  WRITE_FLAG( ( sei.m_noIntraLayerColPicFlag ? 1 : 0 ), "no_intra_layer_col_pic_flag" );
1061};
1062
1063#if NH_MV_SEI_TBD
1064Void SEIWriter::xWriteSEIFrameFieldInfo( const SEIFrameFieldInfo& sei)
1065{
1066  WRITE_CODE( sei.m_ffinfoPicStruct, 4, "ffinfo_pic_struct" );
1067  WRITE_CODE( sei.m_ffinfoSourceScanType, 2, "ffinfo_source_scan_type" );
1068  WRITE_FLAG( ( sei.m_ffinfoDuplicateFlag ? 1 : 0 ), "ffinfo_duplicate_flag" );
1069};
1070
1071Void SEIWriter::xWriteSEIThreeDimensionalReferenceDisplaysInfo( const SEIThreeDimensionalReferenceDisplaysInfo& sei)
1072{
1073  WRITE_UVLC( sei.m_precRefDisplayWidth, "prec_ref_display_width" );
1074  WRITE_FLAG( ( sei.m_refViewingDistanceFlag ? 1 : 0 ), "ref_viewing_distance_flag" );
1075  if( sei.m_refViewingDistanceFlag )
1076  {
1077    WRITE_UVLC( sei.m_precRefViewingDist, "prec_ref_viewing_dist" );
1078  }
1079  WRITE_UVLC( sei.m_numRefDisplaysMinus1, "num_ref_displays_minus1" );
1080  for( Int i = 0; i  <=  NumRefDisplaysMinus1( ); i++ )
1081  {
1082    WRITE_UVLC( sei.m_leftViewId[i], "left_view_id" );
1083    WRITE_UVLC( sei.m_rightViewId[i], "right_view_id" );
1084    WRITE_CODE( sei.m_exponentRefDisplayWidth[i], 6, "exponent_ref_display_width" );
1085    WRITE_CODE( sei.m_mantissaRefDisplayWidth[i], getMantissaRefDisplayWidthLen ), "mantissa_ref_display_width" );
1086    if( sei.m_refViewingDistanceFlag )
1087    {
1088      WRITE_CODE( sei.m_exponentRefViewingDistance[i], 6, "exponent_ref_viewing_distance" );
1089      WRITE_CODE( sei.m_mantissaRefViewingDistance[i], getMantissaRefViewingDistanceLen ), "mantissa_ref_viewing_distance" );
1090    }
1091    WRITE_FLAG( ( sei.m_additionalShiftPresentFlag[i] ? 1 : 0 ), "additional_shift_present_flag" );
1092    if( sei.m_additionalShiftPresentFlag( i ) )
1093    {
1094      WRITE_CODE( sei.m_numSampleShiftPlus512[i], 10, "num_sample_shift_plus512" );
1095    }
1096  }
1097  WRITE_FLAG( ( sei.m_threeDimensionalReferenceDisplaysExtensionFlag ? 1 : 0 ), "three_dimensional_reference_displays_extension_flag" );
1098};
1099
1100Void SEIWriter::xWriteSEIDepthRepresentationInfo( const SEIDepthRepresentationInfo& sei)
1101{
1102  WRITE_FLAG( ( sei.m_zNearFlag ? 1 : 0 ), "z_near_flag" );
1103  WRITE_FLAG( ( sei.m_zFarFlag ? 1 : 0 ), "z_far_flag" );
1104  WRITE_FLAG( ( sei.m_dMinFlag ? 1 : 0 ), "d_min_flag" );
1105  WRITE_FLAG( ( sei.m_dMaxFlag ? 1 : 0 ), "d_max_flag" );
1106  WRITE_UVLC( sei.m_depthRepresentationType, "depth_representation_type" );
1107  if( sei.m_dMinFlag  | |  sei.m_dMaxFlag )
1108  {
1109    WRITE_UVLC( sei.m_disparityRefViewId, "disparity_ref_view_id" );
1110  }
1111  if( sei.m_zNearFlag )
1112  {
1113    DepthRepInfoElement(() ZNearSign, ZNearExp, ZNearMantissa, ZNearManLen );
1114  }
1115  if( sei.m_zFarFlag )
1116  {
1117    DepthRepInfoElement(() ZFarSign, ZFarExp, ZFarMantissa, ZFarManLen );
1118  }
1119  if( sei.m_dMinFlag )
1120  {
1121    DepthRepInfoElement(() DMinSign, DMinExp, DMinMantissa, DMinManLen );
1122  }
1123  if( sei.m_dMaxFlag )
1124  {
1125    DepthRepInfoElement(() DMaxSign, DMaxExp, DMaxMantissa, DMaxManLen );
1126  }
1127  if( sei.m_depthRepresentationType  ==  3 )
1128  {
1129    WRITE_UVLC( sei.m_depthNonlinearRepresentationNumMinus1, "depth_nonlinear_representation_num_minus1" );
1130    for( Int i = 1; i  <=  sei.m_depthNonlinearRepresentationNumMinus1 + 1; i++ )
1131    {
1132      DepthNonlinearRepresentationModel( i );
1133    }
1134  }
1135};
1136
1137Void SEIWriter::xWriteSEIDepthRepInfoElement( const SEIDepthRepInfoElement& sei)
1138{
1139  WRITE_FLAG( ( sei.m_daSignFlag ? 1 : 0 ), "da_sign_flag" );
1140  WRITE_CODE( sei.m_daExponent, 7, "da_exponent" );
1141  WRITE_CODE( sei.m_daMantissaLenMinus1, 5, "da_mantissa_len_minus1" );
1142  WRITE_CODE( sei.m_daMantissa, getDaMantissaLen ), "da_mantissa" );
1143};
1144
1145#endif
1146Void SEIWriter::xWriteSEIMultiviewSceneInfo( const SEIMultiviewSceneInfo& sei)
1147{
1148  WRITE_SVLC( sei.m_minDisparity     , "min_disparity"       );
1149  WRITE_UVLC( sei.m_maxDisparityRange, "max_disparity_range" );
1150};
1151
1152
1153Void SEIWriter::xWriteSEIMultiviewAcquisitionInfo( const SEIMultiviewAcquisitionInfo& sei)
1154{
1155  WRITE_FLAG( ( sei.m_intrinsicParamFlag ? 1 : 0 ), "intrinsic_param_flag" );
1156  WRITE_FLAG( ( sei.m_extrinsicParamFlag ? 1 : 0 ), "extrinsic_param_flag" );
1157  if( sei.m_intrinsicParamFlag )
1158  {
1159    WRITE_FLAG( ( sei.m_intrinsicParamsEqualFlag ? 1 : 0 ), "intrinsic_params_equal_flag" );
1160    WRITE_UVLC(   sei.m_precFocalLength                   , "prec_focal_length"           );
1161    WRITE_UVLC(   sei.m_precPrincipalPoint                , "prec_principal_point"        );
1162    WRITE_UVLC(   sei.m_precSkewFactor                    , "prec_skew_factor"            );
1163
1164    for( Int i = 0; i  <=  ( sei.m_intrinsicParamsEqualFlag ? 0 : sei.getNumViewsMinus1() ); i++ )
1165    {
1166      WRITE_FLAG( ( sei.m_signFocalLengthX       [i] ? 1 : 0 ),                                         "sign_focal_length_x"        );
1167      WRITE_CODE(   sei.m_exponentFocalLengthX   [i]          , 6                                  ,    "exponent_focal_length_x"    );
1168      WRITE_CODE(   sei.m_mantissaFocalLengthX   [i]          , sei.getMantissaFocalLengthXLen( i ),    "mantissa_focal_length_x"    );
1169      WRITE_FLAG( ( sei.m_signFocalLengthY       [i] ? 1 : 0 ),                                         "sign_focal_length_y"        );
1170      WRITE_CODE(   sei.m_exponentFocalLengthY   [i]          , 6                                  ,    "exponent_focal_length_y"    );
1171      WRITE_CODE(   sei.m_mantissaFocalLengthY   [i]          , sei.getMantissaFocalLengthYLen( i ),    "mantissa_focal_length_y"    );
1172      WRITE_FLAG( ( sei.m_signPrincipalPointX    [i] ? 1 : 0 ),                                         "sign_principal_point_x"     );
1173      WRITE_CODE(   sei.m_exponentPrincipalPointX[i]          , 6,                                      "exponent_principal_point_x" );
1174      WRITE_CODE(   sei.m_mantissaPrincipalPointX[i]          , sei.getMantissaPrincipalPointXLen( i ), "mantissa_principal_point_x" );
1175      WRITE_FLAG( ( sei.m_signPrincipalPointY    [i] ? 1 : 0 ),                                         "sign_principal_point_y"     );
1176      WRITE_CODE(   sei.m_exponentPrincipalPointY[i]          , 6,                                      "exponent_principal_point_y" );
1177      WRITE_CODE(   sei.m_mantissaPrincipalPointY[i]          , sei.getMantissaPrincipalPointYLen( i ), "mantissa_principal_point_y" );
1178      WRITE_FLAG( ( sei.m_signSkewFactor         [i] ? 1 : 0 ),                                         "sign_skew_factor"           );
1179      WRITE_CODE(   sei.m_exponentSkewFactor     [i]          , 6,                                      "exponent_skew_factor"       );
1180      WRITE_CODE(   sei.m_mantissaSkewFactor     [i]          , sei.getMantissaSkewFactorLen( i )  ,    "mantissa_skew_factor"       );
1181    }
1182  }
1183  if( sei.m_extrinsicParamFlag )
1184  {
1185    WRITE_UVLC( sei.m_precRotationParam   , "prec_rotation_param"    );
1186    WRITE_UVLC( sei.m_precTranslationParam, "prec_translation_param" );
1187    for( Int i = 0; i  <=  sei.getNumViewsMinus1(); i++ )
1188    {
1189      for( Int j = 0; j  <=  2; j++ )  /* row */
1190      {
1191        for( Int k = 0; k  <=  2; k++ )  /* column */
1192        {
1193          WRITE_FLAG( ( sei.m_signR    [i][j][k] ? 1 : 0 ),                                "sign_r"     );
1194          WRITE_CODE(   sei.m_exponentR[i][j][k]          , 6,                             "exponent_r" );
1195          WRITE_CODE(   sei.m_mantissaR[i][j][k]          , sei.getMantissaRLen( i,j,k ) , "mantissa_r" );
1196        }
1197        WRITE_FLAG( ( sei.m_signT    [i][j] ? 1 : 0 ),                          "sign_t"     );
1198        WRITE_CODE(   sei.m_exponentT[i][j]          , 6,                       "exponent_t" );
1199        WRITE_CODE(   sei.m_mantissaT[i][j]          , sei.getMantissaTLen( i,j ),"mantissa_t" );
1200      }
1201    }
1202  }
1203};
1204
1205
1206#if NH_MV_SEI
1207Void SEIWriter::xWriteSEIMultiviewViewPosition( const SEIMultiviewViewPosition& sei)
1208{
1209  WRITE_UVLC( sei.m_numViewsMinus1, "num_views_minus1" );
1210  for( Int i = 0; i  <=  sei.m_numViewsMinus1; i++ )
1211  {
1212    WRITE_UVLC( sei.m_viewPosition[i], "view_position" );
1213  }
1214};
1215#endif
1216
1217#if NH_MV_SEI_TBD
1218Void SEIWriter::xWriteSEIAlternativeDepthInfo( const SEIAlternativeDepthInfo& sei)
1219{
1220  WRITE_FLAG( ( sei.m_alternativeDepthInfoCancelFlag ? 1 : 0 ), "alternative_depth_info_cancel_flag" );
1221  if( sei.m_alternativeDepthInfoCancelFlag  ==  0 )
1222  {
1223    WRITE_CODE( sei.m_depthType, 2, "depth_type" );
1224    if( sei.m_depthType  ==  0 )
1225    {
1226      WRITE_UVLC( sei.m_numConstituentViewsGvdMinus1, "num_constituent_views_gvd_minus1" );
1227      WRITE_FLAG( ( sei.m_depthPresentGvdFlag ? 1 : 0 ), "depth_present_gvd_flag" );
1228      WRITE_FLAG( ( sei.m_zGvdFlag ? 1 : 0 ), "z_gvd_flag" );
1229      WRITE_FLAG( ( sei.m_intrinsicParamGvdFlag ? 1 : 0 ), "intrinsic_param_gvd_flag" );
1230      WRITE_FLAG( ( sei.m_rotationGvdFlag ? 1 : 0 ), "rotation_gvd_flag" );
1231      WRITE_FLAG( ( sei.m_translationGvdFlag ? 1 : 0 ), "translation_gvd_flag" );
1232      if( sei.m_zGvdFlag )
1233      {
1234        for( Int i = 0; i  <=  sei.m_numConstituentViewsGvdMinus1 + 1; i++ )
1235        {
1236          WRITE_FLAG( ( sei.m_signGvdZNearFlag[i] ? 1 : 0 ), "sign_gvd_z_near_flag" );
1237          WRITE_CODE( sei.m_expGvdZNear[i], 7, "exp_gvd_z_near" );
1238          WRITE_CODE( sei.m_manLenGvdZNearMinus1[i], 5, "man_len_gvd_z_near_minus1" );
1239          WRITE_CODE( sei.m_manGvdZNear[i], getManGvdZNearLen ), "man_gvd_z_near" );
1240          WRITE_FLAG( ( sei.m_signGvdZFarFlag[i] ? 1 : 0 ), "sign_gvd_z_far_flag" );
1241          WRITE_CODE( sei.m_expGvdZFar[i], 7, "exp_gvd_z_far" );
1242          WRITE_CODE( sei.m_manLenGvdZFarMinus1[i], 5, "man_len_gvd_z_far_minus1" );
1243          WRITE_CODE( sei.m_manGvdZFar[i], getManGvdZFarLen ), "man_gvd_z_far" );
1244        }
1245      }
1246      if( sei.m_intrinsicParamGvdFlag )
1247      {
1248        WRITE_UVLC( sei.m_precGvdFocalLength, "prec_gvd_focal_length" );
1249        WRITE_UVLC( sei.m_precGvdPrincipalPoint, "prec_gvd_principal_point" );
1250      }
1251      if( sei.m_rotationGvdFlag )
1252      {
1253        WRITE_UVLC( sei.m_precGvdRotationParam, "prec_gvd_rotation_param" );
1254      }
1255      if( sei.m_translationGvdFlag )
1256      {
1257        WRITE_UVLC( sei.m_precGvdTranslationParam, "prec_gvd_translation_param" );
1258      }
1259      for( Int i = 0; i  <=  sei.m_numConstituentViewsGvdMinus1 + 1; i++ )
1260      {
1261        if( sei.m_intrinsicParamGvdFlag )
1262        {
1263          WRITE_FLAG( ( sei.m_signGvdFocalLengthX[i] ? 1 : 0 ), "sign_gvd_focal_length_x" );
1264          WRITE_CODE( sei.m_expGvdFocalLengthX[i], 6, "exp_gvd_focal_length_x" );
1265          WRITE_CODE( sei.m_manGvdFocalLengthX[i], getManGvdFocalLengthXLen ), "man_gvd_focal_length_x" );
1266          WRITE_FLAG( ( sei.m_signGvdFocalLengthY[i] ? 1 : 0 ), "sign_gvd_focal_length_y" );
1267          WRITE_CODE( sei.m_expGvdFocalLengthY[i], 6, "exp_gvd_focal_length_y" );
1268          WRITE_CODE( sei.m_manGvdFocalLengthY[i], getManGvdFocalLengthYLen ), "man_gvd_focal_length_y" );
1269          WRITE_FLAG( ( sei.m_signGvdPrincipalPointX[i] ? 1 : 0 ), "sign_gvd_principal_point_x" );
1270          WRITE_CODE( sei.m_expGvdPrincipalPointX[i], 6, "exp_gvd_principal_point_x" );
1271          WRITE_CODE( sei.m_manGvdPrincipalPointX[i], getManGvdPrincipalPointXLen ), "man_gvd_principal_point_x" );
1272          WRITE_FLAG( ( sei.m_signGvdPrincipalPointY[i] ? 1 : 0 ), "sign_gvd_principal_point_y" );
1273          WRITE_CODE( sei.m_expGvdPrincipalPointY[i], 6, "exp_gvd_principal_point_y" );
1274          WRITE_CODE( sei.m_manGvdPrincipalPointY[i], getManGvdPrincipalPointYLen ), "man_gvd_principal_point_y" );
1275        }
1276        if( sei.m_rotationGvdFlag )
1277        {
1278          for( Int j = 10; j  <=  3; j++ ) /* row */
1279          {
1280            for( Int k = 10; k  <=  3; k++ )  /* column */
1281            {
1282              WRITE_FLAG( ( sei.m_signGvdR[i][j][k] ? 1 : 0 ), "sign_gvd_r" );
1283              WRITE_CODE( sei.m_expGvdR[i][j][k], 6, "exp_gvd_r" );
1284              WRITE_CODE( sei.m_manGvdR[i][j][k], getManGvdRLen ), "man_gvd_r" );
1285            }
1286          }
1287        }
1288        if( sei.m_translationGvdFlag )
1289        {
1290          WRITE_FLAG( ( sei.m_signGvdTX[i] ? 1 : 0 ), "sign_gvd_t_x" );
1291          WRITE_CODE( sei.m_expGvdTX[i], 6, "exp_gvd_t_x" );
1292          WRITE_CODE( sei.m_manGvdTX[i], getManGvdTXLen ), "man_gvd_t_x" );
1293        }
1294      }
1295    }
1296    if( sei.m_depthType  ==  1 )
1297    {
1298      WRITE_SVLC( sei.m_minOffsetXInt, "min_offset_x_int" );
1299      WRITE_CODE( sei.m_minOffsetXFrac, 8, "min_offset_x_frac" );
1300      WRITE_SVLC( sei.m_maxOffsetXInt, "max_offset_x_int" );
1301      WRITE_CODE( sei.m_maxOffsetXFrac, 8, "max_offset_x_frac" );
1302      WRITE_FLAG( ( sei.m_offsetYPresentFlag ? 1 : 0 ), "offset_y_present_flag" );
1303      if( sei.m_offsetYPresentFlag )
1304      {
1305        WRITE_SVLC( sei.m_minOffsetYInt, "min_offset_y_int" );
1306        WRITE_CODE( sei.m_minOffsetYFrac, 8, "min_offset_y_frac" );
1307        WRITE_SVLC( sei.m_maxOffsetYInt, "max_offset_y_int" );
1308        WRITE_CODE( sei.m_maxOffsetYFrac, 8, "max_offset_y_frac" );
1309      }
1310      WRITE_FLAG( ( sei.m_warpMapSizePresentFlag ? 1 : 0 ), "warp_map_size_present_flag" );
1311      if( sei.m_warpMapSizePresentFlag )
1312      {
1313        WRITE_UVLC( sei.m_warpMapWidthMinus2, "warp_map_width_minus2" );
1314        WRITE_UVLC( sei.m_warpMapHeightMinus2, "warp_map_height_minus2" );
1315      }
1316    }
1317  }
1318};
1319
1320#endif
1321
1322//! \}
Note: See TracBrowser for help on using the repository browser.