Changeset 1413 in 3DVCSoftware for trunk/source/Lib/TLibDecoder/SEIread.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/TLibDecoder/SEIread.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 *
     
    201201    switch (payloadType)
    202202    {
     203    case SEI::BUFFERING_PERIOD:
     204      if (!sps)
     205      {
     206        printf ("Warning: Found Buffering period SEI message, but no active SPS is available. Ignoring.");
     207      }
     208      else
     209      {
     210        sei = new SEIBufferingPeriod;
     211        xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps, pDecodedMessageOutputStream);
     212      }
     213      break;
     214    case SEI::PICTURE_TIMING:
     215      if (!sps)
     216      {
     217        printf ("Warning: Found Picture timing SEI message, but no active SPS is available. Ignoring.");
     218      }
     219      else
     220      {
     221        sei = new SEIPictureTiming;
     222        xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps, pDecodedMessageOutputStream);
     223      }
     224      break;
     225    case SEI::PAN_SCAN_RECT:
     226      sei = new SEIPanScanRect;
     227      xParseSEIPanScanRect((SEIPanScanRect&) *sei, payloadSize, pDecodedMessageOutputStream);
     228      break;
     229    case SEI::FILLER_PAYLOAD:
     230      sei = new SEIFillerPayload;
     231      xParseSEIFillerPayload((SEIFillerPayload&) *sei, payloadSize, pDecodedMessageOutputStream);
     232      break;
     233    case SEI::USER_DATA_REGISTERED_ITU_T_T35:
     234      sei = new SEIUserDataRegistered;
     235      xParseSEIUserDataRegistered((SEIUserDataRegistered&) *sei, payloadSize, pDecodedMessageOutputStream);
     236      break;
    203237    case SEI::USER_DATA_UNREGISTERED:
    204       sei = new SEIuserDataUnregistered;
    205       xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream);
     238      sei = new SEIUserDataUnregistered;
     239      xParseSEIUserDataUnregistered((SEIUserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream);
     240      break;
     241    case SEI::RECOVERY_POINT:
     242      sei = new SEIRecoveryPoint;
     243      xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize, pDecodedMessageOutputStream);
     244      break;
     245    case SEI::SCENE_INFO:
     246      sei = new SEISceneInfo;
     247      xParseSEISceneInfo((SEISceneInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
     248      break;
     249    case SEI::PICTURE_SNAPSHOT:
     250      sei = new SEIPictureSnapshot;
     251      xParseSEIPictureSnapshot((SEIPictureSnapshot&) *sei, payloadSize, pDecodedMessageOutputStream);
     252      break;
     253    case SEI::PROGRESSIVE_REFINEMENT_SEGMENT_START:
     254      sei = new SEIProgressiveRefinementSegmentStart;
     255      xParseSEIProgressiveRefinementSegmentStart((SEIProgressiveRefinementSegmentStart&) *sei, payloadSize, pDecodedMessageOutputStream);
     256      break;
     257    case SEI::PROGRESSIVE_REFINEMENT_SEGMENT_END:
     258      sei = new SEIProgressiveRefinementSegmentEnd;
     259      xParseSEIProgressiveRefinementSegmentEnd((SEIProgressiveRefinementSegmentEnd&) *sei, payloadSize, pDecodedMessageOutputStream);
     260      break;
     261    case SEI::FILM_GRAIN_CHARACTERISTICS:
     262      sei = new SEIFilmGrainCharacteristics;
     263      xParseSEIFilmGrainCharacteristics((SEIFilmGrainCharacteristics&) *sei, payloadSize, pDecodedMessageOutputStream);
     264      break;
     265    case SEI::POST_FILTER_HINT:
     266      if (!sps)
     267      {
     268        printf ("Warning: post filter hint SEI message, but no active SPS is available. Ignoring.");
     269      }
     270      else
     271      {
     272        sei = new SEIPostFilterHint;
     273        xParseSEIPostFilterHint((SEIPostFilterHint&) *sei, payloadSize, sps, pDecodedMessageOutputStream);
     274      }
     275      break;
     276    case SEI::TONE_MAPPING_INFO:
     277      sei = new SEIToneMappingInfo;
     278      xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
     279      break;
     280    case SEI::FRAME_PACKING:
     281      sei = new SEIFramePacking;
     282      xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream);
     283      break;
     284    case SEI::DISPLAY_ORIENTATION:
     285      sei = new SEIDisplayOrientation;
     286      xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize, pDecodedMessageOutputStream);
     287      break;
     288    case SEI::GREEN_METADATA:
     289      sei = new SEIGreenMetadataInfo;
     290      xParseSEIGreenMetadataInfo((SEIGreenMetadataInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
     291      break;
     292    case SEI::SOP_DESCRIPTION:
     293      sei = new SEISOPDescription;
     294      xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize, pDecodedMessageOutputStream);
    206295      break;
    207296    case SEI::ACTIVE_PARAMETER_SETS:
     
    220309      }
    221310      break;
    222     case SEI::BUFFERING_PERIOD:
    223       if (!sps)
    224       {
    225         printf ("Warning: Found Buffering period SEI message, but no active SPS is available. Ignoring.");
    226       }
    227       else
    228       {
    229         sei = new SEIBufferingPeriod;
    230         xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps, pDecodedMessageOutputStream);
    231       }
    232       break;
    233     case SEI::PICTURE_TIMING:
    234       if (!sps)
    235       {
    236         printf ("Warning: Found Picture timing SEI message, but no active SPS is available. Ignoring.");
    237       }
    238       else
    239       {
    240         sei = new SEIPictureTiming;
    241         xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps, pDecodedMessageOutputStream);
    242       }
    243       break;
    244     case SEI::RECOVERY_POINT:
    245       sei = new SEIRecoveryPoint;
    246       xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize, pDecodedMessageOutputStream);
    247       break;
    248     case SEI::FRAME_PACKING:
    249       sei = new SEIFramePacking;
    250       xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream);
     311    case SEI::TEMPORAL_LEVEL0_INDEX:
     312      sei = new SEITemporalLevel0Index;
     313      xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize, pDecodedMessageOutputStream);
     314      break;
     315#if NH_MV
     316      xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, vps, sps, pDecodedMessageOutputStream);
     317#else
     318    case SEI::SCALABLE_NESTING:
     319      sei = new SEIScalableNesting;
     320      xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps, pDecodedMessageOutputStream);
     321#endif
     322      break;
     323    case SEI::REGION_REFRESH_INFO:
     324      sei = new SEIRegionRefreshInfo;
     325      xParseSEIRegionRefreshInfo((SEIRegionRefreshInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
     326      break;
     327    case SEI::NO_DISPLAY:
     328      sei = new SEINoDisplay;
     329      xParseSEINoDisplay((SEINoDisplay&) *sei, payloadSize, pDecodedMessageOutputStream);
     330      break;
     331    case SEI::TIME_CODE:
     332      sei = new SEITimeCode;
     333      xParseSEITimeCode((SEITimeCode&) *sei, payloadSize, pDecodedMessageOutputStream);
     334      break;
     335    case SEI::MASTERING_DISPLAY_COLOUR_VOLUME:
     336      sei = new SEIMasteringDisplayColourVolume;
     337      xParseSEIMasteringDisplayColourVolume((SEIMasteringDisplayColourVolume&) *sei, payloadSize, pDecodedMessageOutputStream);
    251338      break;
    252339    case SEI::SEGM_RECT_FRAME_PACKING:
     
    254341      xParseSEISegmentedRectFramePacking((SEISegmentedRectFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream);
    255342      break;
    256     case SEI::DISPLAY_ORIENTATION:
    257       sei = new SEIDisplayOrientation;
    258       xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize, pDecodedMessageOutputStream);
    259       break;
    260     case SEI::TEMPORAL_LEVEL0_INDEX:
    261       sei = new SEITemporalLevel0Index;
    262       xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize, pDecodedMessageOutputStream);
    263       break;
    264     case SEI::REGION_REFRESH_INFO:
    265       sei = new SEIGradualDecodingRefreshInfo;
    266       xParseSEIRegionRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
    267       break;
    268     case SEI::NO_DISPLAY:
    269       sei = new SEINoDisplay;
    270       xParseSEINoDisplay((SEINoDisplay&) *sei, payloadSize, pDecodedMessageOutputStream);
    271       break;
    272     case SEI::TONE_MAPPING_INFO:
    273       sei = new SEIToneMappingInfo;
    274       xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
    275       break;
    276     case SEI::SOP_DESCRIPTION:
    277       sei = new SEISOPDescription;
    278       xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize, pDecodedMessageOutputStream);
    279       break;
    280     case SEI::SCALABLE_NESTING:
    281       sei = new SEIScalableNesting;
    282 #if NH_MV
    283       xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, vps, sps, pDecodedMessageOutputStream);
    284 #else
    285       xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps, pDecodedMessageOutputStream);
    286 #endif
    287       break;
    288343    case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS:
    289344      sei = new SEITempMotionConstrainedTileSets;
    290345      xParseSEITempMotionConstraintsTileSets((SEITempMotionConstrainedTileSets&) *sei, payloadSize, pDecodedMessageOutputStream);
    291346      break;
    292     case SEI::TIME_CODE:
    293       sei = new SEITimeCode;
    294       xParseSEITimeCode((SEITimeCode&) *sei, payloadSize, pDecodedMessageOutputStream);
    295       break;
    296347    case SEI::CHROMA_RESAMPLING_FILTER_HINT:
    297348      sei = new SEIChromaResamplingFilterHint;
    298349      xParseSEIChromaResamplingFilterHint((SEIChromaResamplingFilterHint&) *sei, payloadSize, pDecodedMessageOutputStream);
    299       //}
    300350      break;
    301351    case SEI::KNEE_FUNCTION_INFO:
     
    307357      xParseSEIColourRemappingInfo((SEIColourRemappingInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
    308358      break;
    309     case SEI::MASTERING_DISPLAY_COLOUR_VOLUME:
    310       sei = new SEIMasteringDisplayColourVolume;
    311       xParseSEIMasteringDisplayColourVolume((SEIMasteringDisplayColourVolume&) *sei, payloadSize, pDecodedMessageOutputStream);
    312       break;
    313 #if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI
     359    case SEI::DEINTERLACE_FIELD_IDENTIFICATION:
     360      sei = new SEIDeinterlaceFieldIdentification;
     361      xParseSEIDeinterlaceFieldIdentification((SEIDeinterlaceFieldIdentification&) *sei, payloadSize, pDecodedMessageOutputStream);
     362      break;
     363    case SEI::CONTENT_LIGHT_LEVEL_INFO:
     364      sei = new SEIContentLightLevelInfo;
     365      xParseSEIContentLightLevelInfo((SEIContentLightLevelInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
     366      break;
     367    case SEI::DEPENDENT_RAP_INDICATION:
     368      sei = new SEIDependentRAPIndication;
     369      xParseSEIDependentRAPIndication((SEIDependentRAPIndication&) *sei, payloadSize, pDecodedMessageOutputStream);
     370      break;
     371    case SEI::CODED_REGION_COMPLETION:
     372      sei = new SEICodedRegionCompletion;
     373      xParseSEICodedRegionCompletion((SEICodedRegionCompletion&) *sei, payloadSize, pDecodedMessageOutputStream);
     374      break;
    314375    case SEI::ALTERNATIVE_TRANSFER_CHARACTERISTICS:
    315376      sei = new SEIAlternativeTransferCharacteristics;
    316377      xParseSEIAlternativeTransferCharacteristics((SEIAlternativeTransferCharacteristics&) *sei, payloadSize, pDecodedMessageOutputStream);
    317378      break;
    318 #endif
     379    case SEI::AMBIENT_VIEWING_ENVIRONMENT:
     380      sei = new SEIAmbientViewingEnvironment;
     381      xParseSEIAmbientViewingEnvironment((SEIAmbientViewingEnvironment&) *sei, payloadSize, pDecodedMessageOutputStream);
     382      break;
    319383#if NH_MV
    320384    case SEI::LAYERS_NOT_PRESENT:
     
    412476    switch (payloadType)
    413477    {
     478      case SEI::FILLER_PAYLOAD:
     479        sei = new SEIFillerPayload;
     480        xParseSEIFillerPayload((SEIFillerPayload&) *sei, payloadSize, pDecodedMessageOutputStream);
     481        break;
     482      case SEI::USER_DATA_REGISTERED_ITU_T_T35:
     483        sei = new SEIUserDataRegistered;
     484        xParseSEIUserDataRegistered((SEIUserDataRegistered&) *sei, payloadSize, pDecodedMessageOutputStream);
     485        break;
    414486      case SEI::USER_DATA_UNREGISTERED:
    415         sei = new SEIuserDataUnregistered;
    416         xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream);
     487        sei = new SEIUserDataUnregistered;
     488        xParseSEIUserDataUnregistered((SEIUserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream);
     489        break;
     490      case SEI::PROGRESSIVE_REFINEMENT_SEGMENT_END:
     491        sei = new SEIProgressiveRefinementSegmentEnd;
     492        xParseSEIProgressiveRefinementSegmentEnd((SEIProgressiveRefinementSegmentEnd&) *sei, payloadSize, pDecodedMessageOutputStream);
     493        break;
     494      case SEI::POST_FILTER_HINT:
     495        if (!sps)
     496        {
     497          printf ("Warning: post filter hint SEI message, but no active SPS is available. Ignoring.");
     498        }
     499        else
     500        {
     501          sei = new SEIPostFilterHint;
     502          xParseSEIPostFilterHint((SEIPostFilterHint&) *sei, payloadSize, sps, pDecodedMessageOutputStream);
     503        }
    417504        break;
    418505      case SEI::DECODED_PICTURE_HASH:
    419506        sei = new SEIDecodedPictureHash;
    420507        xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize, pDecodedMessageOutputStream);
     508        break;
     509      case SEI::CODED_REGION_COMPLETION:
     510        sei = new SEICodedRegionCompletion;
     511        xParseSEICodedRegionCompletion((SEICodedRegionCompletion&) *sei, payloadSize, pDecodedMessageOutputStream);
    421512        break;
    422513      default:
     
    484575}
    485576
    486 /**
    487  * parse bitstream bs and unpack a user_data_unregistered SEI message
    488  * of payloasSize bytes into sei.
    489  */
    490 
    491 Void SEIReader::xParseSEIuserDataUnregistered(SEIuserDataUnregistered &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
    492 {
    493   assert(payloadSize >= ISO_IEC_11578_LEN);
    494   UInt val;
    495   output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
    496 
    497   for (UInt i = 0; i < ISO_IEC_11578_LEN; i++)
    498   {
    499     sei_read_code( pDecodedMessageOutputStream, 8, val, "uuid_iso_iec_11578");
    500     sei.uuid_iso_iec_11578[i] = val;
    501   }
    502 
    503   sei.userDataLength = payloadSize - ISO_IEC_11578_LEN;
    504   if (!sei.userDataLength)
    505   {
    506     sei.userData = 0;
    507     return;
    508   }
    509 
    510   sei.userData = new UChar[sei.userDataLength];
    511   for (UInt i = 0; i < sei.userDataLength; i++)
    512   {
    513     sei_read_code( NULL, 8, val, "user_data_payload_byte" );
    514     sei.userData[i] = val;
    515   }
    516   if (pDecodedMessageOutputStream)
    517   {
    518     (*pDecodedMessageOutputStream) << "  User data payload size: " << sei.userDataLength << "\n";
    519   }
    520 }
    521 
    522 /**
    523  * parse bitstream bs and unpack a decoded picture hash SEI message
    524  * of payloadSize bytes into sei.
    525  */
    526 Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
    527 {
    528   UInt bytesRead = 0;
    529   output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
    530 
    531   UInt val;
    532   sei_read_code( pDecodedMessageOutputStream, 8, val, "hash_type");
    533   sei.method = static_cast<HashType>(val); bytesRead++;
    534 
    535   const TChar *traceString="\0";
    536   switch (sei.method)
    537   {
    538     case HASHTYPE_MD5: traceString="picture_md5"; break;
    539     case HASHTYPE_CRC: traceString="picture_crc"; break;
    540     case HASHTYPE_CHECKSUM: traceString="picture_checksum"; break;
    541     default: assert(false); break;
    542   }
    543 
    544   if (pDecodedMessageOutputStream)
    545   {
    546     (*pDecodedMessageOutputStream) << "  " << std::setw(55) << traceString << ": " << std::hex << std::setfill('0');
    547   }
    548 
    549   sei.m_pictureHash.hash.clear();
    550   for(;bytesRead < payloadSize; bytesRead++)
    551   {
    552     sei_read_code( NULL, 8, val, traceString);
    553     sei.m_pictureHash.hash.push_back((UChar)val);
    554     if (pDecodedMessageOutputStream)
    555     {
    556       (*pDecodedMessageOutputStream) << std::setw(2) << val;
    557     }
    558   }
    559 
    560   if (pDecodedMessageOutputStream)
    561   {
    562     (*pDecodedMessageOutputStream) << std::dec << std::setfill(' ') << "\n";
    563   }
    564 }
    565 
    566 Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
    567 {
    568   UInt val;
    569   output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
    570 
    571   sei_read_code( pDecodedMessageOutputStream, 4, val, "active_video_parameter_set_id");   sei.activeVPSId = val;
    572   sei_read_flag( pDecodedMessageOutputStream,    val, "self_contained_cvs_flag");         sei.m_selfContainedCvsFlag     = (val != 0);
    573   sei_read_flag( pDecodedMessageOutputStream,    val, "no_parameter_set_update_flag");    sei.m_noParameterSetUpdateFlag = (val != 0);
    574   sei_read_uvlc( pDecodedMessageOutputStream,    val, "num_sps_ids_minus1");              sei.numSpsIdsMinus1 = val;
    575 
    576   sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1);
    577   for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++)
    578   {
    579     sei_read_uvlc( pDecodedMessageOutputStream, val, "active_seq_parameter_set_id[i]");    sei.activeSeqParameterSetId[i] = val;
    580   }
    581 }
    582 
    583 Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
    584 {
    585   UInt val;
    586   output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
    587   sei_read_uvlc( pDecodedMessageOutputStream, val, "decoding_unit_idx");
    588   sei.m_decodingUnitIdx = val;
    589 
    590   const TComVUI *vui = sps->getVuiParameters();
    591   if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag())
    592   {
    593     sei_read_code( pDecodedMessageOutputStream, ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay_increment");
    594     sei.m_duSptCpbRemovalDelay = val;
    595   }
    596   else
    597   {
    598     sei.m_duSptCpbRemovalDelay = 0;
    599   }
    600   sei_read_flag( pDecodedMessageOutputStream, val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = (val != 0);
    601   if(sei.m_dpbOutputDuDelayPresentFlag)
    602   {
    603     sei_read_code( pDecodedMessageOutputStream, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay");
    604     sei.m_picSptDpbOutputDuDelay = val;
    605   }
    606 }
    607577
    608578Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
     
    713683}
    714684
     685Void SEIReader::xParseSEIPanScanRect(SEIPanScanRect& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     686{
     687  UInt code;
     688  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     689  sei_read_uvlc( pDecodedMessageOutputStream, code, "pan_scan_rect_id" );          sei.m_panScanRectId = code;
     690  sei_read_flag( pDecodedMessageOutputStream, code, "pan_scan_rect_cancel_flag" ); sei.m_panScanRectCancelFlag = code!=0;
     691  if (!sei.m_panScanRectCancelFlag)
     692  {
     693    UInt numRegions;
     694    sei_read_uvlc( pDecodedMessageOutputStream, numRegions, "pan_scan_cnt_minus1" ); numRegions++;
     695    sei.m_panScanRectRegions.resize(numRegions);
     696    for(UInt region=0; region<numRegions; region++)
     697    {
     698      SEIPanScanRect::PanScanRect &rect=sei.m_panScanRectRegions[region];
     699      Int  i;
     700      sei_read_svlc( pDecodedMessageOutputStream, i, "pan_scan_rect_left_offset[i]" );   rect.leftOffset   = i;
     701      sei_read_svlc( pDecodedMessageOutputStream, i, "pan_scan_rect_right_offset[i]" );  rect.rightOffset  = i;
     702      sei_read_svlc( pDecodedMessageOutputStream, i, "pan_scan_rect_top_offset[i]" );    rect.topOffset    = i;
     703      sei_read_svlc( pDecodedMessageOutputStream, i, "pan_scan_rect_bottom_offset[i]" ); rect.bottomOffset = i;
     704    }
     705    sei_read_flag( pDecodedMessageOutputStream, code, "pan_scan_rect_persistence_flag" ); sei.m_panScanRectPersistenceFlag = code!=0;
     706  }
     707  else
     708  {
     709    sei.m_panScanRectRegions.clear();
     710    sei.m_panScanRectPersistenceFlag=false;
     711  }
     712}
     713
     714Void SEIReader::xParseSEIFillerPayload(SEIFillerPayload& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     715{
     716  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     717  sei.m_numFillerFFBytes = payloadSize;
     718  Bool allBytesWereFF=true;
     719  for(UInt k=0; k<payloadSize; k++)
     720  {
     721    UInt code;
     722    sei_read_code( NULL, 8, code, "ff_byte" );
     723    if (code!=0xff) allBytesWereFF=false;
     724  }
     725  if (pDecodedMessageOutputStream && !allBytesWereFF)
     726  {
     727    (*pDecodedMessageOutputStream) << "  not all filler payload bytes were 0xff\n";
     728  }
     729}
     730
     731
     732Void SEIReader::xParseSEIUserDataRegistered(SEIUserDataRegistered& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     733  {
     734  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     735
     736  UInt code;
     737  assert(payloadSize>0);
     738  sei_read_code( pDecodedMessageOutputStream, 8, code, "itu_t_t35_country_code" ); payloadSize--;
     739  if (code == 255)
     740  {
     741    assert(payloadSize>0);
     742    sei_read_code( pDecodedMessageOutputStream, 8, code, "itu_t_t35_country_code_extension_byte" ); payloadSize--;
     743    code+=255;
     744  }
     745  sei.m_ituCountryCode = code;
     746  sei.m_userData.resize(payloadSize);
     747  for (UInt i = 0; i < sei.m_userData.size(); i++)
     748  {
     749    sei_read_code( NULL, 8, code, "itu_t_t35_payload_byte" );
     750    sei.m_userData[i] = code;
     751  }
     752  if (pDecodedMessageOutputStream)
     753  {
     754    (*pDecodedMessageOutputStream) << "  itu_t_t35 payload size: " << sei.m_userData.size() << "\n";
     755  }
     756}
     757
     758Void SEIReader::xParseSEIUserDataUnregistered(SEIUserDataUnregistered &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     759    {
     760  assert(payloadSize >= ISO_IEC_11578_LEN);
     761  UInt val;
     762  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     763
     764  for (UInt i = 0; i < ISO_IEC_11578_LEN; i++)
     765  {
     766    sei_read_code( pDecodedMessageOutputStream, 8, val, "uuid_iso_iec_11578");
     767    sei.m_uuid_iso_iec_11578[i] = val;
     768    }
     769  sei.m_userData.resize(payloadSize - ISO_IEC_11578_LEN);
     770  for (UInt i = 0; i < sei.m_userData.size(); i++)
     771  {
     772    sei_read_code( NULL, 8, val, "user_data_payload_byte" );
     773    sei.m_userData[i] = val;
     774  }
     775  if (pDecodedMessageOutputStream)
     776  {
     777    (*pDecodedMessageOutputStream) << "  User data payload size: " << sei.m_userData.size() << "\n";
     778  }
     779}
     780
     781
    715782Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
    716783{
     
    724791}
    725792
    726 Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
    727 {
    728   UInt val;
    729   output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
    730 
    731   sei_read_uvlc( pDecodedMessageOutputStream, val, "frame_packing_arrangement_id" );                 sei.m_arrangementId = val;
    732   sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_cancel_flag" );        sei.m_arrangementCancelFlag = val;
    733 
    734   if ( !sei.m_arrangementCancelFlag )
    735   {
    736     sei_read_code( pDecodedMessageOutputStream, 7, val, "frame_packing_arrangement_type" );          sei.m_arrangementType = val;
    737     assert((sei.m_arrangementType > 2) && (sei.m_arrangementType < 6) );
    738 
    739     sei_read_flag( pDecodedMessageOutputStream, val, "quincunx_sampling_flag" );                     sei.m_quincunxSamplingFlag = val;
    740 
    741     sei_read_code( pDecodedMessageOutputStream, 6, val, "content_interpretation_type" );             sei.m_contentInterpretationType = val;
    742     sei_read_flag( pDecodedMessageOutputStream, val, "spatial_flipping_flag" );                      sei.m_spatialFlippingFlag = val;
    743     sei_read_flag( pDecodedMessageOutputStream, val, "frame0_flipped_flag" );                        sei.m_frame0FlippedFlag = val;
    744     sei_read_flag( pDecodedMessageOutputStream, val, "field_views_flag" );                           sei.m_fieldViewsFlag = val;
    745     sei_read_flag( pDecodedMessageOutputStream, val, "current_frame_is_frame0_flag" );               sei.m_currentFrameIsFrame0Flag = val;
    746     sei_read_flag( pDecodedMessageOutputStream, val, "frame0_self_contained_flag" );                 sei.m_frame0SelfContainedFlag = val;
    747     sei_read_flag( pDecodedMessageOutputStream, val, "frame1_self_contained_flag" );                 sei.m_frame1SelfContainedFlag = val;
    748 
    749     if ( sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5)
    750     {
    751       sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_x" );                sei.m_frame0GridPositionX = val;
    752       sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_y" );                sei.m_frame0GridPositionY = val;
    753       sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_x" );                sei.m_frame1GridPositionX = val;
    754       sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_y" );                sei.m_frame1GridPositionY = val;
    755     }
    756 
    757     sei_read_code( pDecodedMessageOutputStream, 8, val, "frame_packing_arrangement_reserved_byte" );   sei.m_arrangementReservedByte = val;
    758     sei_read_flag( pDecodedMessageOutputStream, val,  "frame_packing_arrangement_persistence_flag" );  sei.m_arrangementPersistenceFlag = (val != 0);
    759   }
    760   sei_read_flag( pDecodedMessageOutputStream, val, "upsampled_aspect_ratio_flag" );                  sei.m_upsampledAspectRatio = val;
    761 }
    762 
    763 Void SEIReader::xParseSEISegmentedRectFramePacking(SEISegmentedRectFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
    764 {
    765   UInt val;
    766   output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
    767   sei_read_flag( pDecodedMessageOutputStream, val,       "segmented_rect_frame_packing_arrangement_cancel_flag" );       sei.m_arrangementCancelFlag            = val;
    768   if( !sei.m_arrangementCancelFlag )
    769   {
    770     sei_read_code( pDecodedMessageOutputStream, 2, val, "segmented_rect_content_interpretation_type" );                sei.m_contentInterpretationType = val;
    771     sei_read_flag( pDecodedMessageOutputStream, val,     "segmented_rect_frame_packing_arrangement_persistence" );                              sei.m_arrangementPersistenceFlag               = val;
    772   }
    773 }
    774 
    775 Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
    776 {
    777   UInt val;
    778   output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
    779   sei_read_flag( pDecodedMessageOutputStream, val,       "display_orientation_cancel_flag" );       sei.cancelFlag            = val;
    780   if( !sei.cancelFlag )
    781   {
    782     sei_read_flag( pDecodedMessageOutputStream, val,     "hor_flip" );                              sei.horFlip               = val;
    783     sei_read_flag( pDecodedMessageOutputStream, val,     "ver_flip" );                              sei.verFlip               = val;
    784     sei_read_code( pDecodedMessageOutputStream, 16, val, "anticlockwise_rotation" );                sei.anticlockwiseRotation = val;
    785     sei_read_flag( pDecodedMessageOutputStream, val,     "display_orientation_persistence_flag" );  sei.persistenceFlag       = val;
    786   }
    787 }
    788 
    789 Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
    790 {
    791   UInt val;
    792   output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
    793   sei_read_code( pDecodedMessageOutputStream, 8, val, "temporal_sub_layer_zero_idx" );  sei.tl0Idx = val;
    794   sei_read_code( pDecodedMessageOutputStream, 8, val, "irap_pic_id" );  sei.rapIdx = val;
    795 }
    796 
    797 Void SEIReader::xParseSEIRegionRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
    798 {
    799   UInt val;
    800   output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
    801   sei_read_flag( pDecodedMessageOutputStream, val, "refreshed_region_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0;
    802 }
    803 
    804 Void SEIReader::xParseSEINoDisplay(SEINoDisplay& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
    805 {
    806   output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
    807   sei.m_noDisplay = true;
    808 }
     793
     794Void SEIReader::xParseSEISceneInfo(SEISceneInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     795  {
     796  UInt code;
     797  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     798
     799  sei_read_flag( pDecodedMessageOutputStream, code, "scene_info_present_flag" ); sei.m_bSceneInfoPresentFlag = code!=0;
     800  if (sei.m_bSceneInfoPresentFlag)
     801  {
     802    sei_read_flag( pDecodedMessageOutputStream, code, "prev_scene_id_valid_flag" ); sei.m_bPrevSceneIdValidFlag = code!=0;
     803    sei_read_uvlc( pDecodedMessageOutputStream, code, "scene_id" );                 sei.m_sceneId = code;
     804    sei_read_uvlc( pDecodedMessageOutputStream, code, "scene_transition_type" );    sei.m_sceneTransitionType = code;
     805    if (sei.m_sceneTransitionType > 3)
     806    {
     807      sei_read_uvlc( pDecodedMessageOutputStream, code, "second_scene_id" );        sei.m_secondSceneId = code;
     808    }
     809    else
     810    {
     811      sei.m_secondSceneId = 0; // set to known value.
     812    }
     813  }
     814}
     815
     816Void SEIReader::xParseSEIPictureSnapshot(SEIPictureSnapshot& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     817{
     818  UInt code;
     819  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     820
     821  sei_read_uvlc( pDecodedMessageOutputStream, code, "snapshot_id" ); sei.m_snapshotId = code;
     822  }
     823
     824
     825Void SEIReader::xParseSEIProgressiveRefinementSegmentStart(SEIProgressiveRefinementSegmentStart& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     826{
     827  UInt code;
     828  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     829
     830  sei_read_uvlc( pDecodedMessageOutputStream, code, "progressive_refinement_id" ); sei.m_progressiveRefinementId = code;
     831  sei_read_uvlc( pDecodedMessageOutputStream, code, "pic_order_cnt_delta" );       sei.m_picOrderCntDelta = code;
     832}
     833
     834
     835Void SEIReader::xParseSEIProgressiveRefinementSegmentEnd(SEIProgressiveRefinementSegmentEnd& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     836{
     837  UInt code;
     838  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     839
     840  sei_read_uvlc( pDecodedMessageOutputStream, code, "progressive_refinement_id" ); sei.m_progressiveRefinementId = code;
     841}
     842
     843
     844Void SEIReader::xParseSEIFilmGrainCharacteristics(SEIFilmGrainCharacteristics& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     845{
     846  UInt code;
     847  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     848
     849  sei_read_flag( pDecodedMessageOutputStream, code, "film_grain_characteristics_cancel_flag" );     sei.m_filmGrainCharacteristicsCancelFlag = code!=0;
     850  if (!sei.m_filmGrainCharacteristicsCancelFlag)
     851  {
     852    sei_read_code( pDecodedMessageOutputStream, 2, code, "film_grain_model_id" );                   sei.m_filmGrainModelId = code;
     853    sei_read_flag( pDecodedMessageOutputStream,    code, "separate_colour_description_present_flag" ); sei.m_separateColourDescriptionPresentFlag = code!=0;
     854    if (sei.m_separateColourDescriptionPresentFlag)
     855    {
     856      sei_read_code( pDecodedMessageOutputStream, 3, code, "film_grain_bit_depth_luma_minus8" );    sei.m_filmGrainBitDepthLumaMinus8      = code;
     857      sei_read_code( pDecodedMessageOutputStream, 3, code, "film_grain_bit_depth_chroma_minus8" );  sei.m_filmGrainBitDepthChromaMinus8    = code;
     858      sei_read_flag( pDecodedMessageOutputStream,    code, "film_grain_full_range_flag" );          sei.m_filmGrainFullRangeFlag           = code!=0;
     859      sei_read_code( pDecodedMessageOutputStream, 8, code, "film_grain_colour_primaries" );         sei.m_filmGrainColourPrimaries         = code;
     860      sei_read_code( pDecodedMessageOutputStream, 8, code, "film_grain_transfer_characteristics" ); sei.m_filmGrainTransferCharacteristics = code;
     861      sei_read_code( pDecodedMessageOutputStream, 8, code, "film_grain_matrix_coeffs" );            sei.m_filmGrainMatrixCoeffs            = code;
     862    }
     863    sei_read_code( pDecodedMessageOutputStream, 2, code, "blending_mode_id" );                      sei.m_blendingModeId                   = code;
     864    sei_read_code( pDecodedMessageOutputStream, 4, code, "log2_scale_factor" );                     sei.m_log2ScaleFactor                  = code;
     865    for(Int c=0; c<3; c++)
     866    {
     867      sei_read_flag( pDecodedMessageOutputStream,    code, "comp_model_present_flag[c]" );          sei.m_compModel[c].bPresentFlag        = code!=0;
     868    }
     869    for(Int c=0; c<3; c++)
     870    {
     871      SEIFilmGrainCharacteristics::CompModel &cm=sei.m_compModel[c];
     872      if (cm.bPresentFlag)
     873      {
     874        UInt numIntensityIntervals;
     875        sei_read_code( pDecodedMessageOutputStream, 8, code, "num_intensity_intervals_minus1[c]" ); numIntensityIntervals = code+1;
     876        sei_read_code( pDecodedMessageOutputStream, 3, code, "num_model_values_minus1[c]" );        cm.numModelValues     = code+1;
     877        cm.intensityValues.resize(numIntensityIntervals);
     878        for(UInt interval=0; interval<numIntensityIntervals; interval++)
     879        {
     880          SEIFilmGrainCharacteristics::CompModelIntensityValues &cmiv=cm.intensityValues[interval];
     881          sei_read_code( pDecodedMessageOutputStream, 8, code, "intensity_interval_lower_bound[c][i]" ); cmiv.intensityIntervalLowerBound=code;
     882          sei_read_code( pDecodedMessageOutputStream, 8, code, "intensity_interval_upper_bound[c][i]" ); cmiv.intensityIntervalUpperBound=code;
     883          cmiv.compModelValue.resize(cm.numModelValues);
     884          for(UInt j=0; j<cm.numModelValues; j++)
     885          {
     886            sei_read_svlc( pDecodedMessageOutputStream, cmiv.compModelValue[j], "comp_model_value[c][i]" );
     887          }
     888        }
     889      }
     890    } // for c
     891    sei_read_flag( pDecodedMessageOutputStream, code, "film_grain_characteristics_persistence_flag" ); sei.m_filmGrainCharacteristicsPersistenceFlag = code!=0;
     892  } // cancel flag
     893}
     894
     895Void SEIReader::xParseSEIPostFilterHint(SEIPostFilterHint& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
     896{
     897  UInt code;
     898  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     899
     900  sei_read_uvlc( pDecodedMessageOutputStream,    code, "filter_hint_size_y" ); sei.m_filterHintSizeY = code;
     901  sei_read_uvlc( pDecodedMessageOutputStream,    code, "filter_hint_size_x" ); sei.m_filterHintSizeX = code;
     902  sei_read_code( pDecodedMessageOutputStream, 2, code, "filter_hint_type"   ); sei.m_filterHintType  = code;
     903
     904  sei.m_bIsMonochrome = (sps->getChromaFormatIdc() == CHROMA_400);
     905  const UInt numChromaChannels = sei.m_bIsMonochrome ? 1:3;
     906
     907  sei.m_filterHintValues.resize(numChromaChannels * sei.m_filterHintSizeX * sei.m_filterHintSizeY);
     908  for(std::size_t i=0; i<sei.m_filterHintValues.size(); i++)
     909  {
     910    Int v;
     911    sei_read_svlc( pDecodedMessageOutputStream, v, "filter_hint_value[][][]" ); sei.m_filterHintValues[i] = code;
     912
     913}
     914}
     915
    809916
    810917Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     
    8931000}
    8941001
     1002
     1003Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     1004{
     1005  UInt val;
     1006  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     1007
     1008  sei_read_uvlc( pDecodedMessageOutputStream, val, "frame_packing_arrangement_id" );                 sei.m_arrangementId = val;
     1009  sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_cancel_flag" );        sei.m_arrangementCancelFlag = val;
     1010
     1011  if ( !sei.m_arrangementCancelFlag )
     1012  {
     1013    sei_read_code( pDecodedMessageOutputStream, 7, val, "frame_packing_arrangement_type" );          sei.m_arrangementType = val;
     1014    assert((sei.m_arrangementType > 2) && (sei.m_arrangementType < 6) );
     1015
     1016    sei_read_flag( pDecodedMessageOutputStream, val, "quincunx_sampling_flag" );                     sei.m_quincunxSamplingFlag = val;
     1017
     1018    sei_read_code( pDecodedMessageOutputStream, 6, val, "content_interpretation_type" );             sei.m_contentInterpretationType = val;
     1019    sei_read_flag( pDecodedMessageOutputStream, val, "spatial_flipping_flag" );                      sei.m_spatialFlippingFlag = val;
     1020    sei_read_flag( pDecodedMessageOutputStream, val, "frame0_flipped_flag" );                        sei.m_frame0FlippedFlag = val;
     1021    sei_read_flag( pDecodedMessageOutputStream, val, "field_views_flag" );                           sei.m_fieldViewsFlag = val;
     1022    sei_read_flag( pDecodedMessageOutputStream, val, "current_frame_is_frame0_flag" );               sei.m_currentFrameIsFrame0Flag = val;
     1023    sei_read_flag( pDecodedMessageOutputStream, val, "frame0_self_contained_flag" );                 sei.m_frame0SelfContainedFlag = val;
     1024    sei_read_flag( pDecodedMessageOutputStream, val, "frame1_self_contained_flag" );                 sei.m_frame1SelfContainedFlag = val;
     1025
     1026    if ( sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5)
     1027    {
     1028      sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_x" );                sei.m_frame0GridPositionX = val;
     1029      sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_y" );                sei.m_frame0GridPositionY = val;
     1030      sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_x" );                sei.m_frame1GridPositionX = val;
     1031      sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_y" );                sei.m_frame1GridPositionY = val;
     1032    }
     1033
     1034    sei_read_code( pDecodedMessageOutputStream, 8, val, "frame_packing_arrangement_reserved_byte" );   sei.m_arrangementReservedByte = val;
     1035    sei_read_flag( pDecodedMessageOutputStream, val,  "frame_packing_arrangement_persistence_flag" );  sei.m_arrangementPersistenceFlag = (val != 0);
     1036  }
     1037  sei_read_flag( pDecodedMessageOutputStream, val, "upsampled_aspect_ratio_flag" );                  sei.m_upsampledAspectRatio = val;
     1038}
     1039
     1040
     1041Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     1042{
     1043  UInt val;
     1044  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     1045  sei_read_flag( pDecodedMessageOutputStream, val,       "display_orientation_cancel_flag" );       sei.cancelFlag            = val;
     1046  if( !sei.cancelFlag )
     1047  {
     1048    sei_read_flag( pDecodedMessageOutputStream, val,     "hor_flip" );                              sei.horFlip               = val;
     1049    sei_read_flag( pDecodedMessageOutputStream, val,     "ver_flip" );                              sei.verFlip               = val;
     1050    sei_read_code( pDecodedMessageOutputStream, 16, val, "anticlockwise_rotation" );                sei.anticlockwiseRotation = val;
     1051    sei_read_flag( pDecodedMessageOutputStream, val,     "display_orientation_persistence_flag" );  sei.persistenceFlag       = val;
     1052  }
     1053}
     1054
     1055
     1056Void SEIReader::xParseSEIGreenMetadataInfo(SEIGreenMetadataInfo& sei, UInt payloadSize, ostream* pDecodedMessageOutputStream)
     1057{
     1058  UInt code;
     1059  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     1060
     1061  sei_read_code(pDecodedMessageOutputStream, 8, code, "green_metadata_type");
     1062  sei.m_greenMetadataType = code;
     1063
     1064  sei_read_code(pDecodedMessageOutputStream, 8, code, "xsd_metric_type");
     1065  sei.m_xsdMetricType = code;
     1066
     1067  sei_read_code(pDecodedMessageOutputStream, 16, code, "xsd_metric_value");
     1068  sei.m_xsdMetricValue = code;
     1069}
     1070
     1071
    8951072Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
    8961073{
     
    9131090      sei_read_svlc( pDecodedMessageOutputStream, iCode,                       "sop_poc_delta[i]"     ); sei.m_sopDescPocDelta[i] = iCode;
    9141091    }
     1092  }
     1093}
     1094
     1095Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     1096{
     1097  UInt val;
     1098  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     1099
     1100  sei_read_code( pDecodedMessageOutputStream, 4, val, "active_video_parameter_set_id");   sei.activeVPSId = val;
     1101  sei_read_flag( pDecodedMessageOutputStream,    val, "self_contained_cvs_flag");         sei.m_selfContainedCvsFlag     = (val != 0);
     1102  sei_read_flag( pDecodedMessageOutputStream,    val, "no_parameter_set_update_flag");    sei.m_noParameterSetUpdateFlag = (val != 0);
     1103  sei_read_uvlc( pDecodedMessageOutputStream,    val, "num_sps_ids_minus1");              sei.numSpsIdsMinus1 = val;
     1104
     1105  sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1);
     1106  for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++)
     1107  {
     1108    sei_read_uvlc( pDecodedMessageOutputStream, val, "active_seq_parameter_set_id[i]");    sei.activeSeqParameterSetId[i] = val;
     1109  }
     1110}
     1111
     1112
     1113Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
     1114{
     1115  UInt val;
     1116  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     1117  sei_read_uvlc( pDecodedMessageOutputStream, val, "decoding_unit_idx");
     1118  sei.m_decodingUnitIdx = val;
     1119
     1120  const TComVUI *vui = sps->getVuiParameters();
     1121  if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag())
     1122  {
     1123    sei_read_code( pDecodedMessageOutputStream, ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay_increment");
     1124    sei.m_duSptCpbRemovalDelay = val;
     1125  }
     1126  else
     1127  {
     1128    sei.m_duSptCpbRemovalDelay = 0;
     1129  }
     1130  sei_read_flag( pDecodedMessageOutputStream, val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = (val != 0);
     1131  if(sei.m_dpbOutputDuDelayPresentFlag)
     1132  {
     1133    sei_read_code( pDecodedMessageOutputStream, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay");
     1134    sei.m_picSptDpbOutputDuDelay = val;
     1135  }
     1136}
     1137
     1138
     1139Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     1140{
     1141  UInt val;
     1142  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     1143  sei_read_code( pDecodedMessageOutputStream, 8, val, "temporal_sub_layer_zero_idx" );  sei.tl0Idx = val;
     1144  sei_read_code( pDecodedMessageOutputStream, 8, val, "irap_pic_id" );  sei.rapIdx = val;
     1145}
     1146
     1147
     1148Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     1149{
     1150  UInt bytesRead = 0;
     1151  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     1152
     1153  UInt val;
     1154  sei_read_code( pDecodedMessageOutputStream, 8, val, "hash_type");
     1155  sei.method = static_cast<HashType>(val); bytesRead++;
     1156
     1157  const TChar *traceString="\0";
     1158  switch (sei.method)
     1159  {
     1160    case HASHTYPE_MD5: traceString="picture_md5"; break;
     1161    case HASHTYPE_CRC: traceString="picture_crc"; break;
     1162    case HASHTYPE_CHECKSUM: traceString="picture_checksum"; break;
     1163    default: assert(false); break;
     1164  }
     1165
     1166  if (pDecodedMessageOutputStream)
     1167  {
     1168    (*pDecodedMessageOutputStream) << "  " << std::setw(55) << traceString << ": " << std::hex << std::setfill('0');
     1169  }
     1170
     1171  sei.m_pictureHash.hash.clear();
     1172  for(;bytesRead < payloadSize; bytesRead++)
     1173  {
     1174    sei_read_code( NULL, 8, val, traceString);
     1175    sei.m_pictureHash.hash.push_back((UChar)val);
     1176    if (pDecodedMessageOutputStream)
     1177    {
     1178      (*pDecodedMessageOutputStream) << std::setw(2) << val;
     1179    }
     1180  }
     1181
     1182  if (pDecodedMessageOutputStream)
     1183  {
     1184    (*pDecodedMessageOutputStream) << std::dec << std::setfill(' ') << "\n";
    9151185  }
    9161186}
     
    9761246
    9771247
    978 Void SEIReader::xParseSEITempMotionConstraintsTileSets(SEITempMotionConstrainedTileSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
    979 {
    980   UInt code;
    981   output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
    982   sei_read_flag( pDecodedMessageOutputStream, code, "mc_all_tiles_exact_sample_value_match_flag");  sei.m_mc_all_tiles_exact_sample_value_match_flag = (code != 0);
    983   sei_read_flag( pDecodedMessageOutputStream, code, "each_tile_one_tile_set_flag");                 sei.m_each_tile_one_tile_set_flag                = (code != 0);
    984 
    985   if(!sei.m_each_tile_one_tile_set_flag)
    986   {
    987     sei_read_flag( pDecodedMessageOutputStream, code, "limited_tile_set_display_flag");  sei.m_limited_tile_set_display_flag = (code != 0);
    988     sei_read_uvlc( pDecodedMessageOutputStream, code, "num_sets_in_message_minus1");     sei.setNumberOfTileSets(code + 1);
    989 
    990     if(sei.getNumberOfTileSets() != 0)
    991     {
    992       for(Int i = 0; i < sei.getNumberOfTileSets(); i++)
    993       {
    994         sei_read_uvlc( pDecodedMessageOutputStream, code, "mcts_id");  sei.tileSetData(i).m_mcts_id = code;
    995 
    996         if(sei.m_limited_tile_set_display_flag)
    997         {
    998           sei_read_flag( pDecodedMessageOutputStream, code, "display_tile_set_flag");  sei.tileSetData(i).m_display_tile_set_flag = (code != 1);
    999         }
    1000 
    1001         sei_read_uvlc( pDecodedMessageOutputStream, code, "num_tile_rects_in_set_minus1");  sei.tileSetData(i).setNumberOfTileRects(code + 1);
    1002 
    1003         for(Int j=0; j<sei.tileSetData(i).getNumberOfTileRects(); j++)
    1004         {
    1005           sei_read_uvlc( pDecodedMessageOutputStream, code, "top_left_tile_index");      sei.tileSetData(i).topLeftTileIndex(j)     = code;
    1006           sei_read_uvlc( pDecodedMessageOutputStream, code, "bottom_right_tile_index");  sei.tileSetData(i).bottomRightTileIndex(j) = code;
    1007         }
    1008 
    1009         if(!sei.m_mc_all_tiles_exact_sample_value_match_flag)
    1010         {
    1011           sei_read_flag( pDecodedMessageOutputStream, code, "exact_sample_value_match_flag");   sei.tileSetData(i).m_exact_sample_value_match_flag    = (code != 0);
    1012         }
    1013         sei_read_flag( pDecodedMessageOutputStream, code, "mcts_tier_level_idc_present_flag");  sei.tileSetData(i).m_mcts_tier_level_idc_present_flag = (code != 0);
    1014 
    1015         if(sei.tileSetData(i).m_mcts_tier_level_idc_present_flag)
    1016         {
    1017           sei_read_flag( pDecodedMessageOutputStream, code,    "mcts_tier_flag"); sei.tileSetData(i).m_mcts_tier_flag = (code != 0);
    1018           sei_read_code( pDecodedMessageOutputStream, 8, code, "mcts_level_idc"); sei.tileSetData(i).m_mcts_level_idc =  code;
    1019         }
    1020       }
    1021     }
    1022   }
    1023   else
    1024   {
    1025     sei_read_flag( pDecodedMessageOutputStream, code, "max_mcs_tier_level_idc_present_flag");  sei.m_max_mcs_tier_level_idc_present_flag = code;
    1026     if(sei.m_max_mcs_tier_level_idc_present_flag)
    1027     {
    1028       sei_read_flag( pDecodedMessageOutputStream, code, "max_mcts_tier_flag");  sei.m_max_mcts_tier_flag = code;
    1029       sei_read_code( pDecodedMessageOutputStream, 8, code, "max_mcts_level_idc"); sei.m_max_mcts_level_idc = code;
    1030     }
    1031   }
    1032 }
     1248Void SEIReader::xParseSEIRegionRefreshInfo(SEIRegionRefreshInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     1249{
     1250  UInt val;
     1251  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     1252  sei_read_flag( pDecodedMessageOutputStream, val, "refreshed_region_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0;
     1253        }
     1254
     1255
     1256Void SEIReader::xParseSEINoDisplay(SEINoDisplay& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     1257        {
     1258  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     1259  sei.m_noDisplay = true;
     1260        }
     1261
    10331262
    10341263Void SEIReader::xParseSEITimeCode(SEITimeCode& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     
    10921321}
    10931322
     1323
     1324Void SEIReader::xParseSEIMasteringDisplayColourVolume(SEIMasteringDisplayColourVolume& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     1325{
     1326  UInt code;
     1327  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     1328
     1329  sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[0]" ); sei.values.primaries[0][0] = code;
     1330  sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[0]" ); sei.values.primaries[0][1] = code;
     1331
     1332  sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[1]" ); sei.values.primaries[1][0] = code;
     1333  sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[1]" ); sei.values.primaries[1][1] = code;
     1334
     1335  sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[2]" ); sei.values.primaries[2][0] = code;
     1336  sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[2]" ); sei.values.primaries[2][1] = code;
     1337
     1338
     1339  sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_x" ); sei.values.whitePoint[0] = code;
     1340  sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_y" ); sei.values.whitePoint[1] = code;
     1341
     1342  sei_read_code( pDecodedMessageOutputStream, 32, code, "max_display_mastering_luminance" ); sei.values.maxLuminance = code;
     1343  sei_read_code( pDecodedMessageOutputStream, 32, code, "min_display_mastering_luminance" ); sei.values.minLuminance = code;
     1344}
     1345
     1346
     1347Void SEIReader::xParseSEISegmentedRectFramePacking(SEISegmentedRectFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     1348{
     1349  UInt val;
     1350  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     1351  sei_read_flag( pDecodedMessageOutputStream, val,       "segmented_rect_frame_packing_arrangement_cancel_flag" );       sei.m_arrangementCancelFlag            = val;
     1352  if( !sei.m_arrangementCancelFlag )
     1353  {
     1354    sei_read_code( pDecodedMessageOutputStream, 2, val, "segmented_rect_content_interpretation_type" );                sei.m_contentInterpretationType = val;
     1355    sei_read_flag( pDecodedMessageOutputStream, val,     "segmented_rect_frame_packing_arrangement_persistence" );                              sei.m_arrangementPersistenceFlag               = val;
     1356  }
     1357}
     1358
     1359
     1360Void SEIReader::xParseSEITempMotionConstraintsTileSets(SEITempMotionConstrainedTileSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
     1361{
     1362  UInt code;
     1363  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     1364  sei_read_flag( pDecodedMessageOutputStream, code, "mc_all_tiles_exact_sample_value_match_flag");  sei.m_mc_all_tiles_exact_sample_value_match_flag = (code != 0);
     1365  sei_read_flag( pDecodedMessageOutputStream, code, "each_tile_one_tile_set_flag");                 sei.m_each_tile_one_tile_set_flag                = (code != 0);
     1366
     1367  if(!sei.m_each_tile_one_tile_set_flag)
     1368  {
     1369    sei_read_flag( pDecodedMessageOutputStream, code, "limited_tile_set_display_flag");  sei.m_limited_tile_set_display_flag = (code != 0);
     1370    sei_read_uvlc( pDecodedMessageOutputStream, code, "num_sets_in_message_minus1");     sei.setNumberOfTileSets(code + 1);
     1371
     1372    if(sei.getNumberOfTileSets() != 0)
     1373    {
     1374      for(Int i = 0; i < sei.getNumberOfTileSets(); i++)
     1375      {
     1376        sei_read_uvlc( pDecodedMessageOutputStream, code, "mcts_id");  sei.tileSetData(i).m_mcts_id = code;
     1377
     1378        if(sei.m_limited_tile_set_display_flag)
     1379        {
     1380          sei_read_flag( pDecodedMessageOutputStream, code, "display_tile_set_flag");  sei.tileSetData(i).m_display_tile_set_flag = (code != 1);
     1381        }
     1382
     1383        sei_read_uvlc( pDecodedMessageOutputStream, code, "num_tile_rects_in_set_minus1");  sei.tileSetData(i).setNumberOfTileRects(code + 1);
     1384
     1385        for(Int j=0; j<sei.tileSetData(i).getNumberOfTileRects(); j++)
     1386        {
     1387          sei_read_uvlc( pDecodedMessageOutputStream, code, "top_left_tile_index");      sei.tileSetData(i).topLeftTileIndex(j)     = code;
     1388          sei_read_uvlc( pDecodedMessageOutputStream, code, "bottom_right_tile_index");  sei.tileSetData(i).bottomRightTileIndex(j) = code;
     1389        }
     1390
     1391        if(!sei.m_mc_all_tiles_exact_sample_value_match_flag)
     1392        {
     1393          sei_read_flag( pDecodedMessageOutputStream, code, "exact_sample_value_match_flag");   sei.tileSetData(i).m_exact_sample_value_match_flag    = (code != 0);
     1394        }
     1395        sei_read_flag( pDecodedMessageOutputStream, code, "mcts_tier_level_idc_present_flag");  sei.tileSetData(i).m_mcts_tier_level_idc_present_flag = (code != 0);
     1396
     1397        if(sei.tileSetData(i).m_mcts_tier_level_idc_present_flag)
     1398        {
     1399          sei_read_flag( pDecodedMessageOutputStream, code,    "mcts_tier_flag"); sei.tileSetData(i).m_mcts_tier_flag = (code != 0);
     1400          sei_read_code( pDecodedMessageOutputStream, 8, code, "mcts_level_idc"); sei.tileSetData(i).m_mcts_level_idc =  code;
     1401        }
     1402      }
     1403    }
     1404  }
     1405  else
     1406  {
     1407    sei_read_flag( pDecodedMessageOutputStream, code, "max_mcs_tier_level_idc_present_flag");  sei.m_max_mcs_tier_level_idc_present_flag = code;
     1408    if(sei.m_max_mcs_tier_level_idc_present_flag)
     1409    {
     1410      sei_read_flag( pDecodedMessageOutputStream, code, "max_mcts_tier_flag");  sei.m_max_mcts_tier_flag = code;
     1411      sei_read_code( pDecodedMessageOutputStream, 8, code, "max_mcts_level_idc"); sei.m_max_mcts_level_idc = code;
     1412    }
     1413  }
     1414}
     1415
     1416
    10941417Void SEIReader::xParseSEIChromaResamplingFilterHint(SEIChromaResamplingFilterHint& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
    10951418{
     
    12561579}
    12571580
    1258 
    1259 Void SEIReader::xParseSEIMasteringDisplayColourVolume(SEIMasteringDisplayColourVolume& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
    1260 {
    1261   UInt code;
    1262   output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
    1263 
    1264   sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[0]" ); sei.values.primaries[0][0] = code;
    1265   sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[0]" ); sei.values.primaries[0][1] = code;
    1266 
    1267   sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[1]" ); sei.values.primaries[1][0] = code;
    1268   sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[1]" ); sei.values.primaries[1][1] = code;
    1269 
    1270   sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[2]" ); sei.values.primaries[2][0] = code;
    1271   sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[2]" ); sei.values.primaries[2][1] = code;
    1272 
    1273 
    1274   sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_x" ); sei.values.whitePoint[0] = code;
    1275   sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_y" ); sei.values.whitePoint[1] = code;
    1276 
    1277   sei_read_code( pDecodedMessageOutputStream, 32, code, "max_display_mastering_luminance" ); sei.values.maxLuminance = code;
    1278   sei_read_code( pDecodedMessageOutputStream, 32, code, "min_display_mastering_luminance" ); sei.values.minLuminance = code;
    1279 }
    1280 
    1281 #if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI
     1581Void SEIReader::xParseSEIDeinterlaceFieldIdentification( SEIDeinterlaceFieldIdentification& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream )
     1582{
     1583  UInt code;
     1584  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     1585
     1586  sei_read_flag(pDecodedMessageOutputStream, code, "deinterlaced_picture_source_parity_flag"); sei.m_deinterlacedPictureSourceParityFlag = code!=0;
     1587}
     1588
     1589
     1590Void SEIReader::xParseSEIContentLightLevelInfo( SEIContentLightLevelInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream )
     1591{
     1592  UInt code;
     1593  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     1594
     1595  sei_read_code(pDecodedMessageOutputStream, 16, code, "max_content_light_level");     sei.m_maxContentLightLevel    = code;
     1596  sei_read_code(pDecodedMessageOutputStream, 16, code, "max_pic_average_light_level"); sei.m_maxPicAverageLightLevel = code;
     1597}
     1598
     1599
     1600Void SEIReader::xParseSEIDependentRAPIndication( SEIDependentRAPIndication& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream )
     1601{
     1602  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     1603}
     1604
     1605
     1606Void SEIReader::xParseSEICodedRegionCompletion( SEICodedRegionCompletion& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream )
     1607{
     1608  UInt code;
     1609  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     1610
     1611  sei_read_uvlc(pDecodedMessageOutputStream, code, "next_segment_address"); sei.m_nextSegmentAddress= code;
     1612  if (code)
     1613  {
     1614    sei_read_flag(pDecodedMessageOutputStream, code, "independent_slice_segment_flag"); sei.m_independentSliceSegmentFlag = code!=0;
     1615  }
     1616  else
     1617  {
     1618    sei.m_independentSliceSegmentFlag=false; // initialise to known value.
     1619  }
     1620}
     1621
     1622
    12821623Void SEIReader::xParseSEIAlternativeTransferCharacteristics(SEIAlternativeTransferCharacteristics& sei, UInt payloadSize, ostream* pDecodedMessageOutputStream)
    12831624{
     
    12871628  sei_read_code(pDecodedMessageOutputStream, 8, code, "preferred_transfer_characteristics"); sei.m_preferredTransferCharacteristics = code;
    12881629}
    1289 #endif
     1630
     1631
     1632Void SEIReader::xParseSEIAmbientViewingEnvironment( SEIAmbientViewingEnvironment& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream )
     1633{
     1634  UInt code;
     1635  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
     1636
     1637  sei_read_code(pDecodedMessageOutputStream, 32, code, "ambient_illuminance"); sei.m_ambientIlluminance= code;
     1638  sei_read_code(pDecodedMessageOutputStream, 16, code, "ambient_light_x");     sei.m_ambientLightX     = (UShort)code;
     1639  sei_read_code(pDecodedMessageOutputStream, 16, code, "ambient_light_y");     sei.m_ambientLightY     = (UShort)code;
     1640}
     1641
    12901642
    12911643#if NH_MV
Note: See TracChangeset for help on using the changeset viewer.