Changeset 1413 in 3DVCSoftware for trunk/source/Lib/TLibEncoder/SEIwrite.cpp


Ignore:
Timestamp:
11 Jul 2018, 15:19:49 (6 years ago)
Author:
tech
Message:

Merged HTM-16.2-dev@1412

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibEncoder/SEIwrite.cpp

    r1405 r1413  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2016, ITU/ISO/IEC
     6 * Copyright (c) 2010-2017, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    5858  switch (sei.payloadType())
    5959  {
     60  case SEI::BUFFERING_PERIOD:
     61    xWriteSEIBufferingPeriod(*static_cast<const SEIBufferingPeriod*>(&sei), sps);
     62    break;
     63  case SEI::PICTURE_TIMING:
     64    xWriteSEIPictureTiming(*static_cast<const SEIPictureTiming*>(&sei), sps);
     65    break;
     66  case SEI::PAN_SCAN_RECT:
     67    xWriteSEIPanScanRect(*static_cast<const SEIPanScanRect*>(&sei));
     68    break;
     69  case SEI::FILLER_PAYLOAD:
     70    xWriteSEIFillerPayload(*static_cast<const SEIFillerPayload*>(&sei));
     71    break;
     72  case SEI::USER_DATA_REGISTERED_ITU_T_T35:
     73    xWriteSEIUserDataRegistered(*static_cast<const SEIUserDataRegistered*>(&sei));
     74    break;
    6075  case SEI::USER_DATA_UNREGISTERED:
    61     xWriteSEIuserDataUnregistered(*static_cast<const SEIuserDataUnregistered*>(&sei));
     76    xWriteSEIUserDataUnregistered(*static_cast<const SEIUserDataUnregistered*>(&sei));
     77    break;
     78  case SEI::RECOVERY_POINT:
     79    xWriteSEIRecoveryPoint(*static_cast<const SEIRecoveryPoint*>(&sei));
     80    break;
     81  case SEI::SCENE_INFO:
     82    xWriteSEISceneInfo(*static_cast<const SEISceneInfo*>(&sei));
     83    break;
     84  case SEI::PICTURE_SNAPSHOT:
     85    xWriteSEIPictureSnapshot(*static_cast<const SEIPictureSnapshot*>(&sei));
     86    break;
     87  case SEI::PROGRESSIVE_REFINEMENT_SEGMENT_START:
     88    xWriteSEIProgressiveRefinementSegmentStart(*static_cast<const SEIProgressiveRefinementSegmentStart*>(&sei));
     89    break;
     90  case SEI::PROGRESSIVE_REFINEMENT_SEGMENT_END:
     91    xWriteSEIProgressiveRefinementSegmentEnd(*static_cast<const SEIProgressiveRefinementSegmentEnd*>(&sei));
     92    break;
     93  case SEI::FILM_GRAIN_CHARACTERISTICS:
     94    xWriteSEIFilmGrainCharacteristics(*static_cast<const SEIFilmGrainCharacteristics*>(&sei));
     95    break;
     96  case SEI::POST_FILTER_HINT:
     97    xWriteSEIPostFilterHint(*static_cast<const SEIPostFilterHint*>(&sei), sps);
     98    break;
     99  case SEI::TONE_MAPPING_INFO:
     100    xWriteSEIToneMappingInfo(*static_cast<const SEIToneMappingInfo*>(&sei));
     101    break;
     102  case SEI::FRAME_PACKING:
     103    xWriteSEIFramePacking(*static_cast<const SEIFramePacking*>(&sei));
     104    break;
     105  case SEI::DISPLAY_ORIENTATION:
     106    xWriteSEIDisplayOrientation(*static_cast<const SEIDisplayOrientation*>(&sei));
     107    break;
     108  case SEI::GREEN_METADATA:
     109      xWriteSEIGreenMetadataInfo(*static_cast<const SEIGreenMetadataInfo*>(&sei));
     110    break;
     111  case SEI::SOP_DESCRIPTION:
     112    xWriteSEISOPDescription(*static_cast<const SEISOPDescription*>(&sei));
    62113    break;
    63114  case SEI::ACTIVE_PARAMETER_SETS:
     
    67118    xWriteSEIDecodingUnitInfo(*static_cast<const SEIDecodingUnitInfo*>(& sei), sps);
    68119    break;
     120  case SEI::TEMPORAL_LEVEL0_INDEX:
     121    xWriteSEITemporalLevel0Index(*static_cast<const SEITemporalLevel0Index*>(&sei));
     122    break;
    69123  case SEI::DECODED_PICTURE_HASH:
    70124    xWriteSEIDecodedPictureHash(*static_cast<const SEIDecodedPictureHash*>(&sei));
    71125    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));
     126  case SEI::SCALABLE_NESTING:
     127    xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), sps);
     128    break;
     129  case SEI::REGION_REFRESH_INFO:
     130    xWriteSEIRegionRefreshInfo(*static_cast<const SEIRegionRefreshInfo*>(&sei));
     131    break;
     132  case SEI::NO_DISPLAY:
     133    xWriteSEINoDisplay(*static_cast<const SEINoDisplay*>(&sei));
     134    break;
     135  case SEI::TIME_CODE:
     136    xWriteSEITimeCode(*static_cast<const SEITimeCode*>(&sei));
     137    break;
     138  case SEI::MASTERING_DISPLAY_COLOUR_VOLUME:
     139    xWriteSEIMasteringDisplayColourVolume(*static_cast<const SEIMasteringDisplayColourVolume*>(&sei));
    83140    break;
    84141  case SEI::SEGM_RECT_FRAME_PACKING:
    85142    xWriteSEISegmentedRectFramePacking(*static_cast<const SEISegmentedRectFramePacking*>(&sei));
    86143    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);
     144  case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS:
     145    xWriteSEITempMotionConstrainedTileSets(*static_cast<const SEITempMotionConstrainedTileSets*>(&sei));
    107146    break;
    108147  case SEI::CHROMA_RESAMPLING_FILTER_HINT:
    109148    xWriteSEIChromaResamplingFilterHint(*static_cast<const SEIChromaResamplingFilterHint*>(&sei));
    110149    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;
    117150  case SEI::KNEE_FUNCTION_INFO:
    118151    xWriteSEIKneeFunctionInfo(*static_cast<const SEIKneeFunctionInfo*>(&sei));
     
    121154    xWriteSEIColourRemappingInfo(*static_cast<const SEIColourRemappingInfo*>(&sei));
    122155    break;
    123   case SEI::MASTERING_DISPLAY_COLOUR_VOLUME:
    124     xWriteSEIMasteringDisplayColourVolume(*static_cast<const SEIMasteringDisplayColourVolume*>(&sei));
    125     break;
    126 #if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI
     156  case SEI::DEINTERLACE_FIELD_IDENTIFICATION:
     157    xWriteSEIDeinterlaceFieldIdentification(*static_cast<const SEIDeinterlaceFieldIdentification*>(&sei));
     158    break;
     159  case SEI::CONTENT_LIGHT_LEVEL_INFO:
     160    xWriteSEIContentLightLevelInfo(*static_cast<const SEIContentLightLevelInfo*>(&sei));
     161    break;
     162  case SEI::DEPENDENT_RAP_INDICATION:
     163    xWriteSEIDependentRAPIndication(*static_cast<const SEIDependentRAPIndication*>(&sei));
     164    break;
     165  case SEI::CODED_REGION_COMPLETION:
     166    xWriteSEICodedRegionCompletion(*static_cast<const SEICodedRegionCompletion*>(&sei));
     167    break;
    127168  case SEI::ALTERNATIVE_TRANSFER_CHARACTERISTICS:
    128169    xWriteSEIAlternativeTransferCharacteristics(*static_cast<const SEIAlternativeTransferCharacteristics*>(&sei));
    129170    break;
    130 #endif
     171  case SEI::AMBIENT_VIEWING_ENVIRONMENT:
     172    xWriteSEIAmbientViewingEnvironment(*static_cast<const SEIAmbientViewingEnvironment*>(&sei));
     173    break;
    131174
    132175#if NH_MV
     
    252295}
    253296
    254 /**
    255  * marshal a user_data_unregistered SEI message sei, storing the marshalled
    256  * representation in bitstream bs.
    257  */
    258 Void 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  */
    275 Void 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 
    296 Void 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 
    311 Void 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 }
    325297
    326298Void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei, const TComSPS *sps)
     
    400372  }
    401373}
     374
     375
     376Void SEIWriter::xWriteSEIPanScanRect(const SEIPanScanRect &sei)
     377{
     378  WRITE_UVLC( sei.m_panScanRectId,         "pan_scan_rect_id" );
     379  const UInt numRegions = (UInt) sei.m_panScanRectRegions.size();
     380  if ( !sei.m_panScanRectCancelFlag && numRegions>0 )
     381  {
     382    WRITE_FLAG( sei.m_panScanRectCancelFlag, "pan_scan_rect_cancel_flag" );
     383    WRITE_UVLC( numRegions - 1, "pan_scan_cnt_minus1" );
     384    for(UInt region=0; region<numRegions; region++)
     385    {
     386      const SEIPanScanRect::PanScanRect &rect=sei.m_panScanRectRegions[region];
     387      WRITE_SVLC( rect.leftOffset,   "pan_scan_rect_left_offset[i]"   );
     388      WRITE_SVLC( rect.rightOffset,  "pan_scan_rect_rioht_offset[i]"  );
     389      WRITE_SVLC( rect.topOffset,    "pan_scan_rect_top_offset[i]"    );
     390      WRITE_SVLC( rect.bottomOffset, "pan_scan_rect_bottom_offset[i]" );
     391    }
     392    WRITE_FLAG( sei.m_panScanRectPersistenceFlag, "pan_scan_rect_persistence_flag" );
     393  }
     394}
     395
     396
     397Void SEIWriter::xWriteSEIFillerPayload(const SEIFillerPayload &sei)
     398{
     399  for(UInt k=0; k<sei.m_numFillerFFBytes; k++)
     400  {
     401    WRITE_CODE( 0xff, 8, "ff_byte" );
     402  }
     403}
     404
     405
     406Void SEIWriter::xWriteSEIUserDataRegistered(const SEIUserDataRegistered &sei)
     407{
     408  WRITE_CODE( (sei.m_ituCountryCode>255) ? 0xff : sei.m_ituCountryCode, 8, "itu_t_t35_country_code" );
     409  if (sei.m_ituCountryCode>=255)
     410  {
     411    assert(sei.m_ituCountryCode < 255+256);
     412    WRITE_CODE( sei.m_ituCountryCode-255, 8, "itu_t_t35_country_code_extension_byte" );
     413  }
     414  for(UInt i=0; i<sei.m_userData.size(); i++)
     415  {
     416    WRITE_CODE( sei.m_userData[i], 8, "itu_t_t35_payload_byte" );
     417  }
     418}
     419
     420
     421Void SEIWriter::xWriteSEIUserDataUnregistered(const SEIUserDataUnregistered &sei)
     422{
     423  for (UInt i = 0; i < ISO_IEC_11578_LEN; i++)
     424  {
     425    WRITE_CODE(sei.m_uuid_iso_iec_11578[i], 8 , "sei.uuid_iso_iec_11578[i]");
     426  }
     427
     428  for (std::size_t i = 0; i < sei.m_userData.size(); i++)
     429  {
     430    WRITE_CODE(sei.m_userData[i], 8 , "user_data");
     431  }
     432}
     433
     434
    402435Void SEIWriter::xWriteSEIRecoveryPoint(const SEIRecoveryPoint& sei)
    403436{
     
    406439  WRITE_FLAG( sei.m_brokenLinkFlag,    "broken_link_flag"    );
    407440}
    408 Void 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 
    442 Void 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" );
     441
     442
     443Void SEIWriter::xWriteSEISceneInfo(const SEISceneInfo &sei)
     444  {
     445  WRITE_FLAG( sei.m_bSceneInfoPresentFlag, "scene_info_present_flag" );
     446  if (sei.m_bSceneInfoPresentFlag)
     447  {
     448    WRITE_FLAG( sei.m_bPrevSceneIdValidFlag, "prev_scene_id_valid_flag" );
     449    WRITE_UVLC( sei.m_sceneId,               "scene_id" );
     450    WRITE_UVLC( sei.m_sceneTransitionType,   "scene_transition_type" );
     451    if (sei.m_sceneTransitionType > 3)
     452    {
     453      WRITE_UVLC( sei.m_secondSceneId,       "second_scene_id" );
     454    }
     455  }
     456}
     457
     458
     459Void SEIWriter::xWriteSEIPictureSnapshot(const SEIPictureSnapshot &sei)
     460{
     461  WRITE_UVLC( sei.m_snapshotId, "snapshot_id" );
     462}
     463
     464Void SEIWriter::xWriteSEIProgressiveRefinementSegmentStart(const SEIProgressiveRefinementSegmentStart &sei)
     465
     466    {
     467  WRITE_UVLC( sei.m_progressiveRefinementId, "progressive_refinement_id" );
     468  WRITE_UVLC( sei.m_picOrderCntDelta,        "pic_order_cnt_delta"       );
     469    }
     470
     471
     472Void SEIWriter::xWriteSEIProgressiveRefinementSegmentEnd(const SEIProgressiveRefinementSegmentEnd &sei)
     473{
     474  WRITE_UVLC( sei.m_progressiveRefinementId, "progressive_refinement_id" );
     475  }
     476
     477
     478Void SEIWriter::xWriteSEIFilmGrainCharacteristics(const SEIFilmGrainCharacteristics &sei)
     479{
     480  WRITE_FLAG( sei.m_filmGrainCharacteristicsCancelFlag, "film_grain_characteristics_cancel_flag" );
     481  if (!sei.m_filmGrainCharacteristicsCancelFlag)
     482  {
     483    WRITE_CODE( sei.m_filmGrainModelId, 2,                  "film_grain_model_id" );
     484    WRITE_FLAG( sei.m_separateColourDescriptionPresentFlag, "separate_colour_description_present_flag" );
     485    if (sei.m_separateColourDescriptionPresentFlag)
     486    {
     487      WRITE_CODE( sei.m_filmGrainBitDepthLumaMinus8,      3, "film_grain_bit_depth_luma_minus8" );
     488      WRITE_CODE( sei.m_filmGrainBitDepthChromaMinus8,    3, "film_grain_bit_depth_chroma_minus8" );
     489      WRITE_FLAG( sei.m_filmGrainFullRangeFlag,              "film_grain_full_range_flag" );
     490      WRITE_CODE( sei.m_filmGrainColourPrimaries,         8, "film_grain_colour_primaries" );
     491      WRITE_CODE( sei.m_filmGrainTransferCharacteristics, 8, "film_grain_transfer_characteristics" );
     492      WRITE_CODE( sei.m_filmGrainMatrixCoeffs,            8, "film_grain_matrix_coeffs" );
     493    }
     494    WRITE_CODE( sei.m_blendingModeId,  2, "blending_mode_id" );
     495    WRITE_CODE( sei.m_log2ScaleFactor, 4, "log2_scale_factor" );
     496    for(Int c=0; c<3; c++)
     497    {
     498      const SEIFilmGrainCharacteristics::CompModel &cm=sei.m_compModel[c];
     499      const UInt numIntensityIntervals = (UInt) cm.intensityValues.size();
     500      const UInt numModelValues        = cm.numModelValues;
     501      WRITE_FLAG( sei.m_compModel[c].bPresentFlag && numIntensityIntervals>0 && numModelValues>0, "comp_model_present_flag[c]" );
     502    }
     503    for(Int c=0; c<3; c++)
     504    {
     505      const SEIFilmGrainCharacteristics::CompModel &cm=sei.m_compModel[c];
     506      const UInt numIntensityIntervals = (UInt) cm.intensityValues.size();
     507      const UInt numModelValues        = cm.numModelValues;
     508      if (cm.bPresentFlag && numIntensityIntervals>0 && numModelValues>0)
     509      {
     510        assert(numIntensityIntervals<=256);
     511        assert(numModelValues<=256);
     512        WRITE_CODE( numIntensityIntervals-1, 8, "num_intensity_intervals_minus1[c]");
     513        WRITE_CODE( numModelValues-1,        8, "num_model_values_minus1[c]");
     514        for(UInt interval=0; interval<numIntensityIntervals; interval++)
     515        {
     516          const SEIFilmGrainCharacteristics::CompModelIntensityValues &cmiv=cm.intensityValues[interval];
     517          WRITE_CODE( cmiv.intensityIntervalLowerBound, 8, "intensity_interval_lower_bound[c][i]" );
     518          WRITE_CODE( cmiv.intensityIntervalUpperBound, 8, "intensity_interval_upper_bound[c][i]" );
     519          assert(cmiv.compModelValue.size() == numModelValues);
     520          for(UInt j=0; j<cm.numModelValues; j++)
     521          {
     522            WRITE_SVLC(cmiv.compModelValue[j], "comp_model_value[c][i]" );
     523          }
     524        }
     525      }
     526    } // for c
     527    WRITE_FLAG( sei.m_filmGrainCharacteristicsPersistenceFlag, "film_grain_characteristics_persistence_flag" );
     528  } // cancel flag
     529}
     530
     531Void SEIWriter::xWriteSEIPostFilterHint(const SEIPostFilterHint& sei, const TComSPS *sps)
     532{
     533  WRITE_UVLC( sei.m_filterHintSizeY,   "filter_hint_size_y" );
     534  WRITE_UVLC( sei.m_filterHintSizeX,   "filter_hint_size_x" );
     535  WRITE_CODE( sei.m_filterHintType, 2, "filter_hint_type"   );
     536  assert( (sps->getChromaFormatIdc() == CHROMA_400) == sei.m_bIsMonochrome );
     537  const UInt numChromaChannels = sei.m_bIsMonochrome ? 1:3;
     538  assert( sei.m_filterHintValues.size() == numChromaChannels*sei.m_filterHintSizeX*sei.m_filterHintSizeY );
     539  for(std::size_t i=0; i<sei.m_filterHintValues.size(); i++)
     540  {
     541    WRITE_SVLC( sei.m_filterHintValues[i], "filter_hint_value[][][]" );
    449542  }
    450543}
     
    525618}
    526619
     620
     621Void SEIWriter::xWriteSEIFramePacking(const SEIFramePacking& sei)
     622{
     623  WRITE_UVLC( sei.m_arrangementId,                  "frame_packing_arrangement_id" );
     624  WRITE_FLAG( sei.m_arrangementCancelFlag,          "frame_packing_arrangement_cancel_flag" );
     625
     626  if( sei.m_arrangementCancelFlag == 0 )
     627  {
     628    WRITE_CODE( sei.m_arrangementType, 7,           "frame_packing_arrangement_type" );
     629
     630    WRITE_FLAG( sei.m_quincunxSamplingFlag,         "quincunx_sampling_flag" );
     631    WRITE_CODE( sei.m_contentInterpretationType, 6, "content_interpretation_type" );
     632    WRITE_FLAG( sei.m_spatialFlippingFlag,          "spatial_flipping_flag" );
     633    WRITE_FLAG( sei.m_frame0FlippedFlag,            "frame0_flipped_flag" );
     634    WRITE_FLAG( sei.m_fieldViewsFlag,               "field_views_flag" );
     635    WRITE_FLAG( sei.m_currentFrameIsFrame0Flag,     "current_frame_is_frame0_flag" );
     636
     637    WRITE_FLAG( sei.m_frame0SelfContainedFlag,      "frame0_self_contained_flag" );
     638    WRITE_FLAG( sei.m_frame1SelfContainedFlag,      "frame1_self_contained_flag" );
     639
     640    if(sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5)
     641    {
     642      WRITE_CODE( sei.m_frame0GridPositionX, 4,     "frame0_grid_position_x" );
     643      WRITE_CODE( sei.m_frame0GridPositionY, 4,     "frame0_grid_position_y" );
     644      WRITE_CODE( sei.m_frame1GridPositionX, 4,     "frame1_grid_position_x" );
     645      WRITE_CODE( sei.m_frame1GridPositionY, 4,     "frame1_grid_position_y" );
     646    }
     647
     648    WRITE_CODE( sei.m_arrangementReservedByte, 8,   "frame_packing_arrangement_reserved_byte" );
     649    WRITE_FLAG( sei.m_arrangementPersistenceFlag,   "frame_packing_arrangement_persistence_flag" );
     650  }
     651
     652  WRITE_FLAG( sei.m_upsampledAspectRatio,           "upsampled_aspect_ratio" );
     653}
     654
     655
    527656Void SEIWriter::xWriteSEIDisplayOrientation(const SEIDisplayOrientation &sei)
    528657{
     
    537666}
    538667
    539 Void SEIWriter::xWriteSEITemporalLevel0Index(const SEITemporalLevel0Index &sei)
    540 {
    541   WRITE_CODE( sei.tl0Idx, 8 , "tl0_idx" );
    542   WRITE_CODE( sei.rapIdx, 8 , "rap_idx" );
    543 }
    544 
    545 Void SEIWriter::xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei)
    546 {
    547   WRITE_FLAG( sei.m_gdrForegroundFlag, "gdr_foreground_flag");
    548 }
    549 
    550 Void SEIWriter::xWriteSEINoDisplay(const SEINoDisplay& /*sei*/)
    551 {
    552 }
     668
     669Void SEIWriter::xWriteSEIGreenMetadataInfo(const SEIGreenMetadataInfo& sei)
     670{
     671  WRITE_CODE(sei.m_greenMetadataType, 8, "green_metadata_type");
     672
     673  WRITE_CODE(sei.m_xsdMetricType, 8, "xsd_metric_type");
     674  WRITE_CODE(sei.m_xsdMetricValue, 16, "xsd_metric_value");
     675}
     676
    553677
    554678Void SEIWriter::xWriteSEISOPDescription(const SEISOPDescription& sei)
     
    571695}
    572696
     697
     698Void SEIWriter::xWriteSEIActiveParameterSets(const SEIActiveParameterSets& sei)
     699{
     700  WRITE_CODE(sei.activeVPSId,     4,         "active_video_parameter_set_id");
     701  WRITE_FLAG(sei.m_selfContainedCvsFlag,     "self_contained_cvs_flag");
     702  WRITE_FLAG(sei.m_noParameterSetUpdateFlag, "no_parameter_set_update_flag");
     703  WRITE_UVLC(sei.numSpsIdsMinus1,            "num_sps_ids_minus1");
     704
     705  assert (sei.activeSeqParameterSetId.size() == (sei.numSpsIdsMinus1 + 1));
     706
     707  for (Int i = 0; i < sei.activeSeqParameterSetId.size(); i++)
     708  {
     709    WRITE_UVLC(sei.activeSeqParameterSetId[i], "active_seq_parameter_set_id");
     710  }
     711}
     712
     713
     714Void SEIWriter::xWriteSEIDecodingUnitInfo(const SEIDecodingUnitInfo& sei, const TComSPS *sps)
     715{
     716  const TComVUI *vui = sps->getVuiParameters();
     717  WRITE_UVLC(sei.m_decodingUnitIdx, "decoding_unit_idx");
     718  if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag())
     719  {
     720    WRITE_CODE( sei.m_duSptCpbRemovalDelay, (vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1), "du_spt_cpb_removal_delay_increment");
     721  }
     722  WRITE_FLAG( sei.m_dpbOutputDuDelayPresentFlag, "dpb_output_du_delay_present_flag");
     723  if(sei.m_dpbOutputDuDelayPresentFlag)
     724  {
     725    WRITE_CODE(sei.m_picSptDpbOutputDuDelay, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, "pic_spt_dpb_output_du_delay");
     726  }
     727}
     728
     729
     730Void SEIWriter::xWriteSEITemporalLevel0Index(const SEITemporalLevel0Index &sei)
     731{
     732  WRITE_CODE( sei.tl0Idx, 8 , "tl0_idx" );
     733  WRITE_CODE( sei.rapIdx, 8 , "rap_idx" );
     734}
     735
     736
     737Void SEIWriter::xWriteSEIDecodedPictureHash(const SEIDecodedPictureHash& sei)
     738{
     739  const TChar *traceString="\0";
     740  switch (sei.method)
     741  {
     742    case HASHTYPE_MD5: traceString="picture_md5"; break;
     743    case HASHTYPE_CRC: traceString="picture_crc"; break;
     744    case HASHTYPE_CHECKSUM: traceString="picture_checksum"; break;
     745    default: assert(false); break;
     746  }
     747
     748  if (traceString != 0) //use of this variable is needed to avoid a compiler error with G++ 4.6.1
     749  {
     750    WRITE_CODE(sei.method, 8, "hash_type");
     751    for(UInt i=0; i<UInt(sei.m_pictureHash.hash.size()); i++)
     752    {
     753      WRITE_CODE(sei.m_pictureHash.hash[i], 8, traceString);
     754    }
     755  }
     756}
     757
     758
    573759Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, const TComSPS *sps)
    574760{
     
    609795}
    610796
    611 Void 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 }
     797Void SEIWriter::xWriteSEIRegionRefreshInfo(const SEIRegionRefreshInfo &sei)
     798        {
     799  WRITE_FLAG( sei.m_gdrForegroundFlag, "gdr_foreground_flag");
     800        }
     801
     802
     803Void SEIWriter::xWriteSEINoDisplay(const SEINoDisplay& /*sei*/)
     804        {
     805  // intentionally empty
     806    }
     807
    667808
    668809Void SEIWriter::xWriteSEITimeCode(const SEITimeCode& sei)
     
    724865}
    725866
     867
     868Void SEIWriter::xWriteSEIMasteringDisplayColourVolume(const SEIMasteringDisplayColourVolume& sei)
     869{
     870  WRITE_CODE( sei.values.primaries[0][0],  16,  "display_primaries_x[0]" );
     871  WRITE_CODE( sei.values.primaries[0][1],  16,  "display_primaries_y[0]" );
     872
     873  WRITE_CODE( sei.values.primaries[1][0],  16,  "display_primaries_x[1]" );
     874  WRITE_CODE( sei.values.primaries[1][1],  16,  "display_primaries_y[1]" );
     875
     876  WRITE_CODE( sei.values.primaries[2][0],  16,  "display_primaries_x[2]" );
     877  WRITE_CODE( sei.values.primaries[2][1],  16,  "display_primaries_y[2]" );
     878
     879  WRITE_CODE( sei.values.whitePoint[0],    16,  "white_point_x" );
     880  WRITE_CODE( sei.values.whitePoint[1],    16,  "white_point_y" );
     881
     882  WRITE_CODE( sei.values.maxLuminance,     32,  "max_display_mastering_luminance" );
     883  WRITE_CODE( sei.values.minLuminance,     32,  "min_display_mastering_luminance" );
     884}
     885
     886
     887Void SEIWriter::xWriteSEISegmentedRectFramePacking(const SEISegmentedRectFramePacking& sei)
     888{
     889  WRITE_FLAG( sei.m_arrangementCancelFlag,          "segmented_rect_frame_packing_arrangement_cancel_flag" );
     890  if( sei.m_arrangementCancelFlag == 0 )
     891  {
     892    WRITE_CODE( sei.m_contentInterpretationType, 2, "segmented_rect_content_interpretation_type" );
     893    WRITE_FLAG( sei.m_arrangementPersistenceFlag,   "segmented_rect_frame_packing_arrangement_persistence" );
     894  }
     895}
     896
     897
     898Void SEIWriter::xWriteSEITempMotionConstrainedTileSets(const SEITempMotionConstrainedTileSets& sei)
     899{
     900  //UInt code;
     901  WRITE_FLAG((sei.m_mc_all_tiles_exact_sample_value_match_flag ? 1 : 0), "mc_all_tiles_exact_sample_value_match_flag");
     902  WRITE_FLAG((sei.m_each_tile_one_tile_set_flag                ? 1 : 0), "each_tile_one_tile_set_flag"               );
     903
     904  if(!sei.m_each_tile_one_tile_set_flag)
     905  {
     906    WRITE_FLAG((sei.m_limited_tile_set_display_flag ? 1 : 0), "limited_tile_set_display_flag");
     907    WRITE_UVLC((sei.getNumberOfTileSets() - 1),               "num_sets_in_message_minus1"   );
     908
     909    if(sei.getNumberOfTileSets() > 0)
     910    {
     911      for(Int i = 0; i < sei.getNumberOfTileSets(); i++)
     912      {
     913        WRITE_UVLC(sei.tileSetData(i).m_mcts_id, "mcts_id");
     914
     915        if(sei.m_limited_tile_set_display_flag)
     916        {
     917          WRITE_FLAG((sei.tileSetData(i).m_display_tile_set_flag ? 1 : 0), "display_tile_set_flag");
     918        }
     919
     920        WRITE_UVLC((sei.tileSetData(i).getNumberOfTileRects() - 1), "num_tile_rects_in_set_minus1");
     921
     922        for(Int j = 0; j < sei.tileSetData(i).getNumberOfTileRects(); j++)
     923        {
     924          WRITE_UVLC(sei.tileSetData(i).topLeftTileIndex    (j), "top_left_tile_index");
     925          WRITE_UVLC(sei.tileSetData(i).bottomRightTileIndex(j), "bottom_right_tile_index");
     926        }
     927
     928        if(!sei.m_mc_all_tiles_exact_sample_value_match_flag)
     929        {
     930          WRITE_FLAG((sei.tileSetData(i).m_exact_sample_value_match_flag ? 1 : 0), "exact_sample_value_match_flag");
     931        }
     932
     933        WRITE_FLAG((sei.tileSetData(i).m_mcts_tier_level_idc_present_flag ? 1 : 0), "mcts_tier_level_idc_present_flag");
     934
     935        if(sei.tileSetData(i).m_mcts_tier_level_idc_present_flag)
     936        {
     937          WRITE_FLAG((sei.tileSetData(i).m_mcts_tier_flag ? 1 : 0), "mcts_tier_flag");
     938          WRITE_CODE( sei.tileSetData(i).m_mcts_level_idc, 8,       "mcts_level_idc");
     939        }
     940      }
     941    }
     942  }
     943  else
     944  {
     945    WRITE_FLAG((sei.m_max_mcs_tier_level_idc_present_flag ? 1 : 0), "max_mcs_tier_level_idc_present_flag");
     946
     947    if(sei.m_max_mcs_tier_level_idc_present_flag)
     948    {
     949      WRITE_FLAG((sei.m_max_mcts_tier_flag ? 1 : 0), "max_mcts_tier_flag");
     950      WRITE_CODE( sei.m_max_mcts_level_idc, 8,       "max_mcts_level_idc");
     951    }
     952  }
     953}
     954
     955
    726956Void SEIWriter::xWriteSEIChromaResamplingFilterHint(const SEIChromaResamplingFilterHint &sei)
    727957{
     
    8461076}
    8471077
    848 Void 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" );
     1078Void SEIWriter::xWriteSEIDeinterlaceFieldIdentification(const SEIDeinterlaceFieldIdentification& sei)
     1079{
     1080  WRITE_FLAG( sei.m_deinterlacedPictureSourceParityFlag, "deinterlaced_picture_source_parity_flag" );
     1081}
     1082
     1083
     1084Void SEIWriter::xWriteSEIContentLightLevelInfo(const SEIContentLightLevelInfo& sei)
     1085{
     1086  WRITE_CODE( sei.m_maxContentLightLevel,    16, "max_content_light_level"     );
     1087  WRITE_CODE( sei.m_maxPicAverageLightLevel, 16, "max_pic_average_light_level" );
     1088}
     1089
     1090
     1091Void SEIWriter::xWriteSEIDependentRAPIndication(const SEIDependentRAPIndication& /*sei*/)
     1092{
     1093  // intentionally empty
     1094}
     1095
     1096
     1097Void SEIWriter::xWriteSEICodedRegionCompletion(const SEICodedRegionCompletion& sei)
     1098{
     1099  WRITE_UVLC( sei.m_nextSegmentAddress, "next_segment_address" );
     1100  if (sei.m_nextSegmentAddress)
     1101  {
     1102    WRITE_FLAG( sei.m_independentSliceSegmentFlag, "independent_slice_segment_flag" );
     1103  }
     1104}
     1105
     1106
     1107Void SEIWriter::xWriteSEIAlternativeTransferCharacteristics(const SEIAlternativeTransferCharacteristics& sei)
     1108{
     1109  WRITE_CODE(sei.m_preferredTransferCharacteristics, 8, "preferred_transfer_characteristics");
     1110}
     1111
     1112
     1113Void SEIWriter::xWriteSEIAmbientViewingEnvironment(const SEIAmbientViewingEnvironment& sei)
     1114{
     1115  WRITE_CODE(sei.m_ambientIlluminance, 32, "ambient_illuminance" );
     1116  WRITE_CODE(sei.m_ambientLightX,      16, "ambient_light_x" );
     1117  WRITE_CODE(sei.m_ambientLightY,      16, "ambient_light_y" );
    8641118}
    8651119
     
    8761130  }
    8771131}
    878 
    879 #if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI
    880 Void SEIWriter::xWriteSEIAlternativeTransferCharacteristics(const SEIAlternativeTransferCharacteristics& sei)
    881 {
    882   WRITE_CODE(sei.m_preferredTransferCharacteristics, 8, "preferred_transfer_characteristics");
    883 }
    884 #endif
    8851132
    8861133#if NH_MV
Note: See TracChangeset for help on using the changeset viewer.