| 1 | /* The copyright in this software is being made available under the BSD |
|---|
| 2 | * License, included below. This software may be subject to other third party |
|---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
|---|
| 4 | * granted under this license. |
|---|
| 5 | * |
|---|
| 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
|---|
| 7 | * All rights reserved. |
|---|
| 8 | * |
|---|
| 9 | * Redistribution and use in source and binary forms, with or without |
|---|
| 10 | * modification, are permitted provided that the following conditions are met: |
|---|
| 11 | * |
|---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
|---|
| 13 | * this list of conditions and the following disclaimer. |
|---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
|---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
|---|
| 16 | * and/or other materials provided with the distribution. |
|---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
|---|
| 18 | * be used to endorse or promote products derived from this software without |
|---|
| 19 | * specific prior written permission. |
|---|
| 20 | * |
|---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
|---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
|---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 32 | */ |
|---|
| 33 | |
|---|
| 34 | /** |
|---|
| 35 | \file SEIread.cpp |
|---|
| 36 | \brief reading funtionality for SEI messages |
|---|
| 37 | */ |
|---|
| 38 | |
|---|
| 39 | #include "TLibCommon/CommonDef.h" |
|---|
| 40 | #include "TLibCommon/TComBitStream.h" |
|---|
| 41 | #include "TLibCommon/SEI.h" |
|---|
| 42 | #include "TLibCommon/TComSlice.h" |
|---|
| 43 | #include "SyntaxElementParser.h" |
|---|
| 44 | #include "SEIread.h" |
|---|
| 45 | #include "TLibCommon/TComPicYuv.h" |
|---|
| 46 | #include <iomanip> |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | //! \ingroup TLibDecoder |
|---|
| 50 | //! \{ |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | #if ENC_DEC_TRACE |
|---|
| 54 | Void xTraceSEIHeader() |
|---|
| 55 | { |
|---|
| 56 | fprintf( g_hTrace, "=========== SEI message ===========\n"); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | Void xTraceSEIMessageType(SEI::PayloadType payloadType) |
|---|
| 60 | { |
|---|
| 61 | fprintf( g_hTrace, "=========== %s SEI message ===========\n", SEI::getSEIMessageString(payloadType)); |
|---|
| 62 | } |
|---|
| 63 | #endif |
|---|
| 64 | |
|---|
| 65 | Void SEIReader::sei_read_code(std::ostream *pOS, UInt uiLength, UInt& ruiCode, const TChar *pSymbolName) |
|---|
| 66 | { |
|---|
| 67 | READ_CODE(uiLength, ruiCode, pSymbolName); |
|---|
| 68 | if (pOS) |
|---|
| 69 | { |
|---|
| 70 | (*pOS) << " " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n"; |
|---|
| 71 | } |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | Void SEIReader::sei_read_uvlc(std::ostream *pOS, UInt& ruiCode, const TChar *pSymbolName) |
|---|
| 75 | { |
|---|
| 76 | READ_UVLC(ruiCode, pSymbolName); |
|---|
| 77 | if (pOS) |
|---|
| 78 | { |
|---|
| 79 | (*pOS) << " " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n"; |
|---|
| 80 | } |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | Void SEIReader::sei_read_svlc(std::ostream *pOS, Int& ruiCode, const TChar *pSymbolName) |
|---|
| 84 | { |
|---|
| 85 | READ_SVLC(ruiCode, pSymbolName); |
|---|
| 86 | if (pOS) |
|---|
| 87 | { |
|---|
| 88 | (*pOS) << " " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n"; |
|---|
| 89 | } |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | Void SEIReader::sei_read_flag(std::ostream *pOS, UInt& ruiCode, const TChar *pSymbolName) |
|---|
| 93 | { |
|---|
| 94 | READ_FLAG(ruiCode, pSymbolName); |
|---|
| 95 | if (pOS) |
|---|
| 96 | { |
|---|
| 97 | (*pOS) << " " << std::setw(55) << pSymbolName << ": " << (ruiCode?1:0) << "\n"; |
|---|
| 98 | } |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | #if NH_MV |
|---|
| 102 | Void SEIReader::sei_read_string(std::ostream *pOS, UInt uiBufSize, UChar* pucCode, UInt& ruiLength, const TChar *pSymbolName) |
|---|
| 103 | { |
|---|
| 104 | READ_STRING(uiBufSize, pucCode, ruiLength, pSymbolName); |
|---|
| 105 | if (pOS) |
|---|
| 106 | { |
|---|
| 107 | (*pOS) << " " << pSymbolName << ": " << (const char*) pucCode << "\n"; |
|---|
| 108 | } |
|---|
| 109 | } |
|---|
| 110 | inline Void SEIReader::output_sei_message_header(SEI &sei, std::ostream *pDecodedMessageOutputStream, UInt payloadSize) |
|---|
| 111 | #else |
|---|
| 112 | static inline Void output_sei_message_header(SEI &sei, std::ostream *pDecodedMessageOutputStream, UInt payloadSize) |
|---|
| 113 | #endif |
|---|
| 114 | { |
|---|
| 115 | if (pDecodedMessageOutputStream) |
|---|
| 116 | { |
|---|
| 117 | std::string seiMessageHdr(SEI::getSEIMessageString(sei.payloadType())); seiMessageHdr+=" SEI message"; |
|---|
| 118 | (*pDecodedMessageOutputStream) << std::setfill('-') << std::setw(seiMessageHdr.size()) << "-" << std::setfill(' ') << "\n" << seiMessageHdr << " (" << payloadSize << " bytes)"<< "\n"; |
|---|
| 119 | #if NH_MV |
|---|
| 120 | (*pDecodedMessageOutputStream) << std::setfill(' ') << "LayerId: " << m_layerId << std::setw(2) << " Picture: " << m_decOrder << std::setw( 5 ) << std::endl; |
|---|
| 121 | #endif |
|---|
| 122 | } |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | #undef READ_CODE |
|---|
| 126 | #undef READ_SVLC |
|---|
| 127 | #undef READ_UVLC |
|---|
| 128 | #undef READ_FLAG |
|---|
| 129 | |
|---|
| 130 | |
|---|
| 131 | /** |
|---|
| 132 | * unmarshal a single SEI message from bitstream bs |
|---|
| 133 | */ |
|---|
| 134 | #if NH_MV |
|---|
| 135 | Void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, const TComVPS *vps, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 136 | #else |
|---|
| 137 | Void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 138 | #endif |
|---|
| 139 | { |
|---|
| 140 | setBitstream(bs); |
|---|
| 141 | |
|---|
| 142 | assert(!m_pcBitstream->getNumBitsUntilByteAligned()); |
|---|
| 143 | do |
|---|
| 144 | { |
|---|
| 145 | #if NH_MV |
|---|
| 146 | xReadSEImessage(seis, nalUnitType, vps, sps, pDecodedMessageOutputStream); |
|---|
| 147 | #else |
|---|
| 148 | xReadSEImessage(seis, nalUnitType, sps, pDecodedMessageOutputStream); |
|---|
| 149 | #endif |
|---|
| 150 | /* SEI messages are an integer number of bytes, something has failed |
|---|
| 151 | * in the parsing if bitstream not byte-aligned */ |
|---|
| 152 | assert(!m_pcBitstream->getNumBitsUntilByteAligned()); |
|---|
| 153 | } |
|---|
| 154 | while (m_pcBitstream->getNumBitsLeft() > 8); |
|---|
| 155 | |
|---|
| 156 | xReadRbspTrailingBits(); |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | #if NH_MV |
|---|
| 160 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, const TComVPS *vps, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 161 | #else |
|---|
| 162 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 163 | #endif |
|---|
| 164 | { |
|---|
| 165 | #if ENC_DEC_TRACE |
|---|
| 166 | xTraceSEIHeader(); |
|---|
| 167 | #endif |
|---|
| 168 | Int payloadType = 0; |
|---|
| 169 | UInt val = 0; |
|---|
| 170 | |
|---|
| 171 | do |
|---|
| 172 | { |
|---|
| 173 | sei_read_code(NULL, 8, val, "payload_type"); |
|---|
| 174 | payloadType += val; |
|---|
| 175 | } while (val==0xFF); |
|---|
| 176 | |
|---|
| 177 | UInt payloadSize = 0; |
|---|
| 178 | do |
|---|
| 179 | { |
|---|
| 180 | sei_read_code(NULL, 8, val, "payload_size"); |
|---|
| 181 | payloadSize += val; |
|---|
| 182 | } while (val==0xFF); |
|---|
| 183 | |
|---|
| 184 | #if ENC_DEC_TRACE |
|---|
| 185 | xTraceSEIMessageType((SEI::PayloadType)payloadType); |
|---|
| 186 | #endif |
|---|
| 187 | |
|---|
| 188 | /* extract the payload for this single SEI message. |
|---|
| 189 | * This allows greater safety in erroneous parsing of an SEI message |
|---|
| 190 | * from affecting subsequent messages. |
|---|
| 191 | * After parsing the payload, bs needs to be restored as the primary |
|---|
| 192 | * bitstream. |
|---|
| 193 | */ |
|---|
| 194 | TComInputBitstream *bs = getBitstream(); |
|---|
| 195 | setBitstream(bs->extractSubstream(payloadSize * 8)); |
|---|
| 196 | |
|---|
| 197 | SEI *sei = NULL; |
|---|
| 198 | |
|---|
| 199 | if(nalUnitType == NAL_UNIT_PREFIX_SEI) |
|---|
| 200 | { |
|---|
| 201 | switch (payloadType) |
|---|
| 202 | { |
|---|
| 203 | case SEI::USER_DATA_UNREGISTERED: |
|---|
| 204 | sei = new SEIuserDataUnregistered; |
|---|
| 205 | xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 206 | break; |
|---|
| 207 | case SEI::ACTIVE_PARAMETER_SETS: |
|---|
| 208 | sei = new SEIActiveParameterSets; |
|---|
| 209 | xParseSEIActiveParameterSets((SEIActiveParameterSets&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 210 | break; |
|---|
| 211 | case SEI::DECODING_UNIT_INFO: |
|---|
| 212 | if (!sps) |
|---|
| 213 | { |
|---|
| 214 | printf ("Warning: Found Decoding unit SEI message, but no active SPS is available. Ignoring."); |
|---|
| 215 | } |
|---|
| 216 | else |
|---|
| 217 | { |
|---|
| 218 | sei = new SEIDecodingUnitInfo; |
|---|
| 219 | xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps, pDecodedMessageOutputStream); |
|---|
| 220 | } |
|---|
| 221 | 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); |
|---|
| 251 | break; |
|---|
| 252 | case SEI::SEGM_RECT_FRAME_PACKING: |
|---|
| 253 | sei = new SEISegmentedRectFramePacking; |
|---|
| 254 | xParseSEISegmentedRectFramePacking((SEISegmentedRectFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 255 | 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; |
|---|
| 288 | case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS: |
|---|
| 289 | sei = new SEITempMotionConstrainedTileSets; |
|---|
| 290 | xParseSEITempMotionConstraintsTileSets((SEITempMotionConstrainedTileSets&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 291 | break; |
|---|
| 292 | case SEI::TIME_CODE: |
|---|
| 293 | sei = new SEITimeCode; |
|---|
| 294 | xParseSEITimeCode((SEITimeCode&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 295 | break; |
|---|
| 296 | case SEI::CHROMA_RESAMPLING_FILTER_HINT: |
|---|
| 297 | sei = new SEIChromaResamplingFilterHint; |
|---|
| 298 | xParseSEIChromaResamplingFilterHint((SEIChromaResamplingFilterHint&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 299 | //} |
|---|
| 300 | break; |
|---|
| 301 | case SEI::KNEE_FUNCTION_INFO: |
|---|
| 302 | sei = new SEIKneeFunctionInfo; |
|---|
| 303 | xParseSEIKneeFunctionInfo((SEIKneeFunctionInfo&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 304 | break; |
|---|
| 305 | case SEI::COLOUR_REMAPPING_INFO: |
|---|
| 306 | sei = new SEIColourRemappingInfo; |
|---|
| 307 | xParseSEIColourRemappingInfo((SEIColourRemappingInfo&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 308 | break; |
|---|
| 309 | case SEI::MASTERING_DISPLAY_COLOUR_VOLUME: |
|---|
| 310 | sei = new SEIMasteringDisplayColourVolume; |
|---|
| 311 | xParseSEIMasteringDisplayColourVolume((SEIMasteringDisplayColourVolume&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 312 | break; |
|---|
| 313 | #if NH_MV |
|---|
| 314 | case SEI::LAYERS_NOT_PRESENT: |
|---|
| 315 | if (!vps) |
|---|
| 316 | { |
|---|
| 317 | printf ("Warning: Found Layers not present SEI message, but no active VPS is available. Ignoring."); |
|---|
| 318 | } |
|---|
| 319 | else |
|---|
| 320 | { |
|---|
| 321 | sei = new SEILayersNotPresent; |
|---|
| 322 | xParseSEILayersNotPresent((SEILayersNotPresent&) *sei, payloadSize, vps, pDecodedMessageOutputStream); |
|---|
| 323 | } |
|---|
| 324 | break; |
|---|
| 325 | case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: |
|---|
| 326 | sei = new SEIInterLayerConstrainedTileSets; |
|---|
| 327 | xParseSEIInterLayerConstrainedTileSets((SEIInterLayerConstrainedTileSets&) *sei, payloadSize, pDecodedMessageOutputStream ); |
|---|
| 328 | break; |
|---|
| 329 | #if NH_MV_TBD |
|---|
| 330 | case SEI::BSP_NESTING: |
|---|
| 331 | sei = new SEIBspNesting; |
|---|
| 332 | xParseSEIBspNesting((SEIBspNesting&) *sei, payloadSize, pDecodedMessageOutputStream ); |
|---|
| 333 | break; |
|---|
| 334 | case SEI::BSP_INITIAL_ARRIVAL_TIME: |
|---|
| 335 | sei = new SEIBspInitialArrivalTime; |
|---|
| 336 | xParseSEIBspInitialArrivalTime((SEIBspInitialArrivalTime&) *sei, payloadSize, pDecodedMessageOutputStream ); |
|---|
| 337 | break; |
|---|
| 338 | #endif |
|---|
| 339 | case SEI::SUB_BITSTREAM_PROPERTY: |
|---|
| 340 | sei = new SEISubBitstreamProperty; |
|---|
| 341 | xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei, payloadSize, pDecodedMessageOutputStream ); |
|---|
| 342 | break; |
|---|
| 343 | case SEI::ALPHA_CHANNEL_INFO: |
|---|
| 344 | sei = new SEIAlphaChannelInfo; |
|---|
| 345 | xParseSEIAlphaChannelInfo((SEIAlphaChannelInfo&) *sei, payloadSize, pDecodedMessageOutputStream ); |
|---|
| 346 | break; |
|---|
| 347 | case SEI::OVERLAY_INFO: |
|---|
| 348 | sei = new SEIOverlayInfo; |
|---|
| 349 | xParseSEIOverlayInfo((SEIOverlayInfo&) *sei, payloadSize, pDecodedMessageOutputStream ); |
|---|
| 350 | break; |
|---|
| 351 | case SEI::TEMPORAL_MV_PREDICTION_CONSTRAINTS: |
|---|
| 352 | sei = new SEITemporalMvPredictionConstraints; |
|---|
| 353 | xParseSEITemporalMvPredictionConstraints((SEITemporalMvPredictionConstraints&) *sei, payloadSize, pDecodedMessageOutputStream ); |
|---|
| 354 | break; |
|---|
| 355 | #if NH_MV_SEI_TBD |
|---|
| 356 | case SEI::FRAME_FIELD_INFO: |
|---|
| 357 | sei = new SEIFrameFieldInfo; |
|---|
| 358 | xParseSEIFrameFieldInfo((SEIFrameFieldInfo&) *sei, payloadSize, pDecodedMessageOutputStream ); |
|---|
| 359 | break; |
|---|
| 360 | #endif |
|---|
| 361 | case SEI::THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO: |
|---|
| 362 | sei = new SEIThreeDimensionalReferenceDisplaysInfo; |
|---|
| 363 | xParseSEIThreeDimensionalReferenceDisplaysInfo((SEIThreeDimensionalReferenceDisplaysInfo&) *sei, payloadSize, pDecodedMessageOutputStream ); |
|---|
| 364 | break; |
|---|
| 365 | case SEI::DEPTH_REPRESENTATION_INFO: |
|---|
| 366 | sei = new SEIDepthRepresentationInfo; |
|---|
| 367 | xParseSEIDepthRepresentationInfo((SEIDepthRepresentationInfo&) *sei, payloadSize, pDecodedMessageOutputStream ); |
|---|
| 368 | break; |
|---|
| 369 | case SEI::MULTIVIEW_SCENE_INFO: |
|---|
| 370 | sei = new SEIMultiviewSceneInfo; |
|---|
| 371 | xParseSEIMultiviewSceneInfo((SEIMultiviewSceneInfo&) *sei, payloadSize, pDecodedMessageOutputStream ); |
|---|
| 372 | break; |
|---|
| 373 | |
|---|
| 374 | case SEI::MULTIVIEW_ACQUISITION_INFO: |
|---|
| 375 | sei = new SEIMultiviewAcquisitionInfo; |
|---|
| 376 | xParseSEIMultiviewAcquisitionInfo((SEIMultiviewAcquisitionInfo&) *sei, payloadSize, pDecodedMessageOutputStream ); |
|---|
| 377 | break; |
|---|
| 378 | |
|---|
| 379 | case SEI::MULTIVIEW_VIEW_POSITION: |
|---|
| 380 | sei = new SEIMultiviewViewPosition; |
|---|
| 381 | xParseSEIMultiviewViewPosition((SEIMultiviewViewPosition&) *sei, payloadSize, pDecodedMessageOutputStream ); |
|---|
| 382 | break; |
|---|
| 383 | #endif |
|---|
| 384 | default: |
|---|
| 385 | for (UInt i = 0; i < payloadSize; i++) |
|---|
| 386 | { |
|---|
| 387 | UInt seiByte; |
|---|
| 388 | sei_read_code (NULL, 8, seiByte, "unknown prefix SEI payload byte"); |
|---|
| 389 | } |
|---|
| 390 | printf ("Unknown prefix SEI message (payloadType = %d) was found!\n", payloadType); |
|---|
| 391 | if (pDecodedMessageOutputStream) |
|---|
| 392 | { |
|---|
| 393 | (*pDecodedMessageOutputStream) << "Unknown prefix SEI message (payloadType = " << payloadType << ") was found!\n"; |
|---|
| 394 | } |
|---|
| 395 | break; |
|---|
| 396 | } |
|---|
| 397 | } |
|---|
| 398 | else |
|---|
| 399 | { |
|---|
| 400 | switch (payloadType) |
|---|
| 401 | { |
|---|
| 402 | case SEI::USER_DATA_UNREGISTERED: |
|---|
| 403 | sei = new SEIuserDataUnregistered; |
|---|
| 404 | xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 405 | break; |
|---|
| 406 | case SEI::DECODED_PICTURE_HASH: |
|---|
| 407 | sei = new SEIDecodedPictureHash; |
|---|
| 408 | xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 409 | break; |
|---|
| 410 | default: |
|---|
| 411 | for (UInt i = 0; i < payloadSize; i++) |
|---|
| 412 | { |
|---|
| 413 | UInt seiByte; |
|---|
| 414 | sei_read_code( NULL, 8, seiByte, "unknown suffix SEI payload byte"); |
|---|
| 415 | } |
|---|
| 416 | printf ("Unknown suffix SEI message (payloadType = %d) was found!\n", payloadType); |
|---|
| 417 | if (pDecodedMessageOutputStream) |
|---|
| 418 | { |
|---|
| 419 | (*pDecodedMessageOutputStream) << "Unknown suffix SEI message (payloadType = " << payloadType << ") was found!\n"; |
|---|
| 420 | } |
|---|
| 421 | break; |
|---|
| 422 | } |
|---|
| 423 | } |
|---|
| 424 | |
|---|
| 425 | if (sei != NULL) |
|---|
| 426 | { |
|---|
| 427 | seis.push_back(sei); |
|---|
| 428 | } |
|---|
| 429 | |
|---|
| 430 | /* By definition the underlying bitstream terminates in a byte-aligned manner. |
|---|
| 431 | * 1. Extract all bar the last MIN(bitsremaining,nine) bits as reserved_payload_extension_data |
|---|
| 432 | * 2. Examine the final 8 bits to determine the payload_bit_equal_to_one marker |
|---|
| 433 | * 3. Extract the remainingreserved_payload_extension_data bits. |
|---|
| 434 | * |
|---|
| 435 | * If there are fewer than 9 bits available, extract them. |
|---|
| 436 | */ |
|---|
| 437 | Int payloadBitsRemaining = getBitstream()->getNumBitsLeft(); |
|---|
| 438 | if (payloadBitsRemaining) /* more_data_in_payload() */ |
|---|
| 439 | { |
|---|
| 440 | for (; payloadBitsRemaining > 9; payloadBitsRemaining--) |
|---|
| 441 | { |
|---|
| 442 | UInt reservedPayloadExtensionData; |
|---|
| 443 | sei_read_code ( pDecodedMessageOutputStream, 1, reservedPayloadExtensionData, "reserved_payload_extension_data"); |
|---|
| 444 | } |
|---|
| 445 | |
|---|
| 446 | /* 2 */ |
|---|
| 447 | Int finalBits = getBitstream()->peekBits(payloadBitsRemaining); |
|---|
| 448 | Int finalPayloadBits = 0; |
|---|
| 449 | for (Int mask = 0xff; finalBits & (mask >> finalPayloadBits); finalPayloadBits++) |
|---|
| 450 | { |
|---|
| 451 | continue; |
|---|
| 452 | } |
|---|
| 453 | |
|---|
| 454 | /* 3 */ |
|---|
| 455 | for (; payloadBitsRemaining > 9 - finalPayloadBits; payloadBitsRemaining--) |
|---|
| 456 | { |
|---|
| 457 | UInt reservedPayloadExtensionData; |
|---|
| 458 | sei_read_flag ( 0, reservedPayloadExtensionData, "reserved_payload_extension_data"); |
|---|
| 459 | } |
|---|
| 460 | |
|---|
| 461 | UInt dummy; |
|---|
| 462 | sei_read_flag( 0, dummy, "payload_bit_equal_to_one"); payloadBitsRemaining--; |
|---|
| 463 | while (payloadBitsRemaining) |
|---|
| 464 | { |
|---|
| 465 | sei_read_flag( 0, dummy, "payload_bit_equal_to_zero"); payloadBitsRemaining--; |
|---|
| 466 | } |
|---|
| 467 | } |
|---|
| 468 | |
|---|
| 469 | /* restore primary bitstream for sei_message */ |
|---|
| 470 | delete getBitstream(); |
|---|
| 471 | setBitstream(bs); |
|---|
| 472 | } |
|---|
| 473 | |
|---|
| 474 | /** |
|---|
| 475 | * parse bitstream bs and unpack a user_data_unregistered SEI message |
|---|
| 476 | * of payloasSize bytes into sei. |
|---|
| 477 | */ |
|---|
| 478 | |
|---|
| 479 | Void SEIReader::xParseSEIuserDataUnregistered(SEIuserDataUnregistered &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 480 | { |
|---|
| 481 | assert(payloadSize >= ISO_IEC_11578_LEN); |
|---|
| 482 | UInt val; |
|---|
| 483 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 484 | |
|---|
| 485 | for (UInt i = 0; i < ISO_IEC_11578_LEN; i++) |
|---|
| 486 | { |
|---|
| 487 | sei_read_code( pDecodedMessageOutputStream, 8, val, "uuid_iso_iec_11578"); |
|---|
| 488 | sei.uuid_iso_iec_11578[i] = val; |
|---|
| 489 | } |
|---|
| 490 | |
|---|
| 491 | sei.userDataLength = payloadSize - ISO_IEC_11578_LEN; |
|---|
| 492 | if (!sei.userDataLength) |
|---|
| 493 | { |
|---|
| 494 | sei.userData = 0; |
|---|
| 495 | return; |
|---|
| 496 | } |
|---|
| 497 | |
|---|
| 498 | sei.userData = new UChar[sei.userDataLength]; |
|---|
| 499 | for (UInt i = 0; i < sei.userDataLength; i++) |
|---|
| 500 | { |
|---|
| 501 | sei_read_code( NULL, 8, val, "user_data_payload_byte" ); |
|---|
| 502 | sei.userData[i] = val; |
|---|
| 503 | } |
|---|
| 504 | if (pDecodedMessageOutputStream) |
|---|
| 505 | { |
|---|
| 506 | (*pDecodedMessageOutputStream) << " User data payload size: " << sei.userDataLength << "\n"; |
|---|
| 507 | } |
|---|
| 508 | } |
|---|
| 509 | |
|---|
| 510 | /** |
|---|
| 511 | * parse bitstream bs and unpack a decoded picture hash SEI message |
|---|
| 512 | * of payloadSize bytes into sei. |
|---|
| 513 | */ |
|---|
| 514 | Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 515 | { |
|---|
| 516 | UInt bytesRead = 0; |
|---|
| 517 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 518 | |
|---|
| 519 | UInt val; |
|---|
| 520 | sei_read_code( pDecodedMessageOutputStream, 8, val, "hash_type"); |
|---|
| 521 | sei.method = static_cast<HashType>(val); bytesRead++; |
|---|
| 522 | |
|---|
| 523 | const TChar *traceString="\0"; |
|---|
| 524 | switch (sei.method) |
|---|
| 525 | { |
|---|
| 526 | case HASHTYPE_MD5: traceString="picture_md5"; break; |
|---|
| 527 | case HASHTYPE_CRC: traceString="picture_crc"; break; |
|---|
| 528 | case HASHTYPE_CHECKSUM: traceString="picture_checksum"; break; |
|---|
| 529 | default: assert(false); break; |
|---|
| 530 | } |
|---|
| 531 | |
|---|
| 532 | if (pDecodedMessageOutputStream) |
|---|
| 533 | { |
|---|
| 534 | (*pDecodedMessageOutputStream) << " " << std::setw(55) << traceString << ": " << std::hex << std::setfill('0'); |
|---|
| 535 | } |
|---|
| 536 | |
|---|
| 537 | sei.m_pictureHash.hash.clear(); |
|---|
| 538 | for(;bytesRead < payloadSize; bytesRead++) |
|---|
| 539 | { |
|---|
| 540 | sei_read_code( NULL, 8, val, traceString); |
|---|
| 541 | sei.m_pictureHash.hash.push_back((UChar)val); |
|---|
| 542 | if (pDecodedMessageOutputStream) |
|---|
| 543 | { |
|---|
| 544 | (*pDecodedMessageOutputStream) << std::setw(2) << val; |
|---|
| 545 | } |
|---|
| 546 | } |
|---|
| 547 | |
|---|
| 548 | if (pDecodedMessageOutputStream) |
|---|
| 549 | { |
|---|
| 550 | (*pDecodedMessageOutputStream) << std::dec << std::setfill(' ') << "\n"; |
|---|
| 551 | } |
|---|
| 552 | } |
|---|
| 553 | |
|---|
| 554 | Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 555 | { |
|---|
| 556 | UInt val; |
|---|
| 557 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 558 | |
|---|
| 559 | sei_read_code( pDecodedMessageOutputStream, 4, val, "active_video_parameter_set_id"); sei.activeVPSId = val; |
|---|
| 560 | sei_read_flag( pDecodedMessageOutputStream, val, "self_contained_cvs_flag"); sei.m_selfContainedCvsFlag = (val != 0); |
|---|
| 561 | sei_read_flag( pDecodedMessageOutputStream, val, "no_parameter_set_update_flag"); sei.m_noParameterSetUpdateFlag = (val != 0); |
|---|
| 562 | sei_read_uvlc( pDecodedMessageOutputStream, val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val; |
|---|
| 563 | |
|---|
| 564 | sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1); |
|---|
| 565 | for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++) |
|---|
| 566 | { |
|---|
| 567 | sei_read_uvlc( pDecodedMessageOutputStream, val, "active_seq_parameter_set_id[i]"); sei.activeSeqParameterSetId[i] = val; |
|---|
| 568 | } |
|---|
| 569 | } |
|---|
| 570 | |
|---|
| 571 | Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 572 | { |
|---|
| 573 | UInt val; |
|---|
| 574 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 575 | sei_read_uvlc( pDecodedMessageOutputStream, val, "decoding_unit_idx"); |
|---|
| 576 | sei.m_decodingUnitIdx = val; |
|---|
| 577 | |
|---|
| 578 | const TComVUI *vui = sps->getVuiParameters(); |
|---|
| 579 | if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag()) |
|---|
| 580 | { |
|---|
| 581 | sei_read_code( pDecodedMessageOutputStream, ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay_increment"); |
|---|
| 582 | sei.m_duSptCpbRemovalDelay = val; |
|---|
| 583 | } |
|---|
| 584 | else |
|---|
| 585 | { |
|---|
| 586 | sei.m_duSptCpbRemovalDelay = 0; |
|---|
| 587 | } |
|---|
| 588 | sei_read_flag( pDecodedMessageOutputStream, val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = (val != 0); |
|---|
| 589 | if(sei.m_dpbOutputDuDelayPresentFlag) |
|---|
| 590 | { |
|---|
| 591 | sei_read_code( pDecodedMessageOutputStream, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay"); |
|---|
| 592 | sei.m_picSptDpbOutputDuDelay = val; |
|---|
| 593 | } |
|---|
| 594 | } |
|---|
| 595 | |
|---|
| 596 | Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 597 | { |
|---|
| 598 | Int i, nalOrVcl; |
|---|
| 599 | UInt code; |
|---|
| 600 | |
|---|
| 601 | const TComVUI *pVUI = sps->getVuiParameters(); |
|---|
| 602 | const TComHRD *pHRD = pVUI->getHrdParameters(); |
|---|
| 603 | |
|---|
| 604 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 605 | |
|---|
| 606 | sei_read_uvlc( pDecodedMessageOutputStream, code, "bp_seq_parameter_set_id" ); sei.m_bpSeqParameterSetId = code; |
|---|
| 607 | if( !pHRD->getSubPicCpbParamsPresentFlag() ) |
|---|
| 608 | { |
|---|
| 609 | sei_read_flag( pDecodedMessageOutputStream, code, "irap_cpb_params_present_flag" ); sei.m_rapCpbParamsPresentFlag = code; |
|---|
| 610 | } |
|---|
| 611 | if( sei.m_rapCpbParamsPresentFlag ) |
|---|
| 612 | { |
|---|
| 613 | sei_read_code( pDecodedMessageOutputStream, pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" ); sei.m_cpbDelayOffset = code; |
|---|
| 614 | sei_read_code( pDecodedMessageOutputStream, pHRD->getDpbOutputDelayLengthMinus1() + 1, code, "dpb_delay_offset" ); sei.m_dpbDelayOffset = code; |
|---|
| 615 | } |
|---|
| 616 | |
|---|
| 617 | //read splicing flag and cpb_removal_delay_delta |
|---|
| 618 | sei_read_flag( pDecodedMessageOutputStream, code, "concatenation_flag"); |
|---|
| 619 | sei.m_concatenationFlag = code; |
|---|
| 620 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" ); |
|---|
| 621 | sei.m_auCpbRemovalDelayDelta = code + 1; |
|---|
| 622 | |
|---|
| 623 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
|---|
| 624 | { |
|---|
| 625 | if( ( ( nalOrVcl == 0 ) && ( pHRD->getNalHrdParametersPresentFlag() ) ) || |
|---|
| 626 | ( ( nalOrVcl == 1 ) && ( pHRD->getVclHrdParametersPresentFlag() ) ) ) |
|---|
| 627 | { |
|---|
| 628 | for( i = 0; i < ( pHRD->getCpbCntMinus1( 0 ) + 1 ); i ++ ) |
|---|
| 629 | { |
|---|
| 630 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_cpb_removal_delay":"nal_initial_cpb_removal_delay" ); |
|---|
| 631 | sei.m_initialCpbRemovalDelay[i][nalOrVcl] = code; |
|---|
| 632 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_cpb_removal_offset":"vcl_initial_cpb_removal_offset" ); |
|---|
| 633 | sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl] = code; |
|---|
| 634 | if( pHRD->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag ) |
|---|
| 635 | { |
|---|
| 636 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_alt_cpb_removal_delay":"vcl_initial_alt_cpb_removal_delay" ); |
|---|
| 637 | sei.m_initialAltCpbRemovalDelay[i][nalOrVcl] = code; |
|---|
| 638 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_alt_cpb_removal_offset":"vcl_initial_alt_cpb_removal_offset" ); |
|---|
| 639 | sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl] = code; |
|---|
| 640 | } |
|---|
| 641 | } |
|---|
| 642 | } |
|---|
| 643 | } |
|---|
| 644 | } |
|---|
| 645 | |
|---|
| 646 | Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 647 | { |
|---|
| 648 | Int i; |
|---|
| 649 | UInt code; |
|---|
| 650 | |
|---|
| 651 | const TComVUI *vui = sps->getVuiParameters(); |
|---|
| 652 | const TComHRD *hrd = vui->getHrdParameters(); |
|---|
| 653 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 654 | |
|---|
| 655 | if( vui->getFrameFieldInfoPresentFlag() ) |
|---|
| 656 | { |
|---|
| 657 | sei_read_code( pDecodedMessageOutputStream, 4, code, "pic_struct" ); sei.m_picStruct = code; |
|---|
| 658 | sei_read_code( pDecodedMessageOutputStream, 2, code, "source_scan_type" ); sei.m_sourceScanType = code; |
|---|
| 659 | sei_read_flag( pDecodedMessageOutputStream, code, "duplicate_flag" ); sei.m_duplicateFlag = (code == 1); |
|---|
| 660 | } |
|---|
| 661 | |
|---|
| 662 | if( hrd->getCpbDpbDelaysPresentFlag()) |
|---|
| 663 | { |
|---|
| 664 | sei_read_code( pDecodedMessageOutputStream, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" ); |
|---|
| 665 | sei.m_auCpbRemovalDelay = code + 1; |
|---|
| 666 | sei_read_code( pDecodedMessageOutputStream, ( hrd->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" ); |
|---|
| 667 | sei.m_picDpbOutputDelay = code; |
|---|
| 668 | |
|---|
| 669 | if(hrd->getSubPicCpbParamsPresentFlag()) |
|---|
| 670 | { |
|---|
| 671 | sei_read_code( pDecodedMessageOutputStream, hrd->getDpbOutputDelayDuLengthMinus1()+1, code, "pic_dpb_output_du_delay" ); |
|---|
| 672 | sei.m_picDpbOutputDuDelay = code; |
|---|
| 673 | } |
|---|
| 674 | |
|---|
| 675 | if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() ) |
|---|
| 676 | { |
|---|
| 677 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_decoding_units_minus1"); |
|---|
| 678 | sei.m_numDecodingUnitsMinus1 = code; |
|---|
| 679 | sei_read_flag( pDecodedMessageOutputStream, code, "du_common_cpb_removal_delay_flag" ); |
|---|
| 680 | sei.m_duCommonCpbRemovalDelayFlag = code; |
|---|
| 681 | if( sei.m_duCommonCpbRemovalDelayFlag ) |
|---|
| 682 | { |
|---|
| 683 | sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_increment_minus1" ); |
|---|
| 684 | sei.m_duCommonCpbRemovalDelayMinus1 = code; |
|---|
| 685 | } |
|---|
| 686 | sei.m_numNalusInDuMinus1.resize(sei.m_numDecodingUnitsMinus1 + 1 ); |
|---|
| 687 | sei.m_duCpbRemovalDelayMinus1.resize( sei.m_numDecodingUnitsMinus1 + 1 ); |
|---|
| 688 | |
|---|
| 689 | for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ ) |
|---|
| 690 | { |
|---|
| 691 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_nalus_in_du_minus1[i]"); |
|---|
| 692 | sei.m_numNalusInDuMinus1[ i ] = code; |
|---|
| 693 | if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) ) |
|---|
| 694 | { |
|---|
| 695 | sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1[i]" ); |
|---|
| 696 | sei.m_duCpbRemovalDelayMinus1[ i ] = code; |
|---|
| 697 | } |
|---|
| 698 | } |
|---|
| 699 | } |
|---|
| 700 | } |
|---|
| 701 | } |
|---|
| 702 | |
|---|
| 703 | Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 704 | { |
|---|
| 705 | Int iCode; |
|---|
| 706 | UInt uiCode; |
|---|
| 707 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 708 | |
|---|
| 709 | sei_read_svlc( pDecodedMessageOutputStream, iCode, "recovery_poc_cnt" ); sei.m_recoveryPocCnt = iCode; |
|---|
| 710 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "exact_matching_flag" ); sei.m_exactMatchingFlag = uiCode; |
|---|
| 711 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "broken_link_flag" ); sei.m_brokenLinkFlag = uiCode; |
|---|
| 712 | } |
|---|
| 713 | |
|---|
| 714 | Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 715 | { |
|---|
| 716 | UInt val; |
|---|
| 717 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 718 | |
|---|
| 719 | sei_read_uvlc( pDecodedMessageOutputStream, val, "frame_packing_arrangement_id" ); sei.m_arrangementId = val; |
|---|
| 720 | sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; |
|---|
| 721 | |
|---|
| 722 | if ( !sei.m_arrangementCancelFlag ) |
|---|
| 723 | { |
|---|
| 724 | sei_read_code( pDecodedMessageOutputStream, 7, val, "frame_packing_arrangement_type" ); sei.m_arrangementType = val; |
|---|
| 725 | assert((sei.m_arrangementType > 2) && (sei.m_arrangementType < 6) ); |
|---|
| 726 | |
|---|
| 727 | sei_read_flag( pDecodedMessageOutputStream, val, "quincunx_sampling_flag" ); sei.m_quincunxSamplingFlag = val; |
|---|
| 728 | |
|---|
| 729 | sei_read_code( pDecodedMessageOutputStream, 6, val, "content_interpretation_type" ); sei.m_contentInterpretationType = val; |
|---|
| 730 | sei_read_flag( pDecodedMessageOutputStream, val, "spatial_flipping_flag" ); sei.m_spatialFlippingFlag = val; |
|---|
| 731 | sei_read_flag( pDecodedMessageOutputStream, val, "frame0_flipped_flag" ); sei.m_frame0FlippedFlag = val; |
|---|
| 732 | sei_read_flag( pDecodedMessageOutputStream, val, "field_views_flag" ); sei.m_fieldViewsFlag = val; |
|---|
| 733 | sei_read_flag( pDecodedMessageOutputStream, val, "current_frame_is_frame0_flag" ); sei.m_currentFrameIsFrame0Flag = val; |
|---|
| 734 | sei_read_flag( pDecodedMessageOutputStream, val, "frame0_self_contained_flag" ); sei.m_frame0SelfContainedFlag = val; |
|---|
| 735 | sei_read_flag( pDecodedMessageOutputStream, val, "frame1_self_contained_flag" ); sei.m_frame1SelfContainedFlag = val; |
|---|
| 736 | |
|---|
| 737 | if ( sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5) |
|---|
| 738 | { |
|---|
| 739 | sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_x" ); sei.m_frame0GridPositionX = val; |
|---|
| 740 | sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_y" ); sei.m_frame0GridPositionY = val; |
|---|
| 741 | sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_x" ); sei.m_frame1GridPositionX = val; |
|---|
| 742 | sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_y" ); sei.m_frame1GridPositionY = val; |
|---|
| 743 | } |
|---|
| 744 | |
|---|
| 745 | sei_read_code( pDecodedMessageOutputStream, 8, val, "frame_packing_arrangement_reserved_byte" ); sei.m_arrangementReservedByte = val; |
|---|
| 746 | sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_persistence_flag" ); sei.m_arrangementPersistenceFlag = (val != 0); |
|---|
| 747 | } |
|---|
| 748 | sei_read_flag( pDecodedMessageOutputStream, val, "upsampled_aspect_ratio_flag" ); sei.m_upsampledAspectRatio = val; |
|---|
| 749 | } |
|---|
| 750 | |
|---|
| 751 | Void SEIReader::xParseSEISegmentedRectFramePacking(SEISegmentedRectFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 752 | { |
|---|
| 753 | UInt val; |
|---|
| 754 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 755 | sei_read_flag( pDecodedMessageOutputStream, val, "segmented_rect_frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; |
|---|
| 756 | if( !sei.m_arrangementCancelFlag ) |
|---|
| 757 | { |
|---|
| 758 | sei_read_code( pDecodedMessageOutputStream, 2, val, "segmented_rect_content_interpretation_type" ); sei.m_contentInterpretationType = val; |
|---|
| 759 | sei_read_flag( pDecodedMessageOutputStream, val, "segmented_rect_frame_packing_arrangement_persistence" ); sei.m_arrangementPersistenceFlag = val; |
|---|
| 760 | } |
|---|
| 761 | } |
|---|
| 762 | |
|---|
| 763 | Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 764 | { |
|---|
| 765 | UInt val; |
|---|
| 766 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 767 | sei_read_flag( pDecodedMessageOutputStream, val, "display_orientation_cancel_flag" ); sei.cancelFlag = val; |
|---|
| 768 | if( !sei.cancelFlag ) |
|---|
| 769 | { |
|---|
| 770 | sei_read_flag( pDecodedMessageOutputStream, val, "hor_flip" ); sei.horFlip = val; |
|---|
| 771 | sei_read_flag( pDecodedMessageOutputStream, val, "ver_flip" ); sei.verFlip = val; |
|---|
| 772 | sei_read_code( pDecodedMessageOutputStream, 16, val, "anticlockwise_rotation" ); sei.anticlockwiseRotation = val; |
|---|
| 773 | sei_read_flag( pDecodedMessageOutputStream, val, "display_orientation_persistence_flag" ); sei.persistenceFlag = val; |
|---|
| 774 | } |
|---|
| 775 | } |
|---|
| 776 | |
|---|
| 777 | Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 778 | { |
|---|
| 779 | UInt val; |
|---|
| 780 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 781 | sei_read_code( pDecodedMessageOutputStream, 8, val, "temporal_sub_layer_zero_idx" ); sei.tl0Idx = val; |
|---|
| 782 | sei_read_code( pDecodedMessageOutputStream, 8, val, "irap_pic_id" ); sei.rapIdx = val; |
|---|
| 783 | } |
|---|
| 784 | |
|---|
| 785 | Void SEIReader::xParseSEIRegionRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 786 | { |
|---|
| 787 | UInt val; |
|---|
| 788 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 789 | sei_read_flag( pDecodedMessageOutputStream, val, "refreshed_region_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0; |
|---|
| 790 | } |
|---|
| 791 | |
|---|
| 792 | Void SEIReader::xParseSEINoDisplay(SEINoDisplay& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 793 | { |
|---|
| 794 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 795 | sei.m_noDisplay = true; |
|---|
| 796 | } |
|---|
| 797 | |
|---|
| 798 | Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 799 | { |
|---|
| 800 | Int i; |
|---|
| 801 | UInt val; |
|---|
| 802 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 803 | sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_id" ); sei.m_toneMapId = val; |
|---|
| 804 | sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_cancel_flag" ); sei.m_toneMapCancelFlag = val; |
|---|
| 805 | |
|---|
| 806 | if ( !sei.m_toneMapCancelFlag ) |
|---|
| 807 | { |
|---|
| 808 | sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_persistence_flag" ); sei.m_toneMapPersistenceFlag = val; |
|---|
| 809 | sei_read_code( pDecodedMessageOutputStream, 8, val, "coded_data_bit_depth" ); sei.m_codedDataBitDepth = val; |
|---|
| 810 | sei_read_code( pDecodedMessageOutputStream, 8, val, "target_bit_depth" ); sei.m_targetBitDepth = val; |
|---|
| 811 | sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_model_id" ); sei.m_modelId = val; |
|---|
| 812 | switch(sei.m_modelId) |
|---|
| 813 | { |
|---|
| 814 | case 0: |
|---|
| 815 | { |
|---|
| 816 | sei_read_code( pDecodedMessageOutputStream, 32, val, "min_value" ); sei.m_minValue = val; |
|---|
| 817 | sei_read_code( pDecodedMessageOutputStream, 32, val, "max_value" ); sei.m_maxValue = val; |
|---|
| 818 | break; |
|---|
| 819 | } |
|---|
| 820 | case 1: |
|---|
| 821 | { |
|---|
| 822 | sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_midpoint" ); sei.m_sigmoidMidpoint = val; |
|---|
| 823 | sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_width" ); sei.m_sigmoidWidth = val; |
|---|
| 824 | break; |
|---|
| 825 | } |
|---|
| 826 | case 2: |
|---|
| 827 | { |
|---|
| 828 | UInt num = 1u << sei.m_targetBitDepth; |
|---|
| 829 | sei.m_startOfCodedInterval.resize(num+1); |
|---|
| 830 | for(i = 0; i < num; i++) |
|---|
| 831 | { |
|---|
| 832 | sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval[i]" ); |
|---|
| 833 | sei.m_startOfCodedInterval[i] = val; |
|---|
| 834 | } |
|---|
| 835 | sei.m_startOfCodedInterval[num] = 1u << sei.m_codedDataBitDepth; |
|---|
| 836 | break; |
|---|
| 837 | } |
|---|
| 838 | case 3: |
|---|
| 839 | { |
|---|
| 840 | sei_read_code( pDecodedMessageOutputStream, 16, val, "num_pivots" ); sei.m_numPivots = val; |
|---|
| 841 | sei.m_codedPivotValue.resize(sei.m_numPivots); |
|---|
| 842 | sei.m_targetPivotValue.resize(sei.m_numPivots); |
|---|
| 843 | for(i = 0; i < sei.m_numPivots; i++ ) |
|---|
| 844 | { |
|---|
| 845 | sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value[i]" ); |
|---|
| 846 | sei.m_codedPivotValue[i] = val; |
|---|
| 847 | sei_read_code( pDecodedMessageOutputStream, ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3), val, "target_pivot_value[i]" ); |
|---|
| 848 | sei.m_targetPivotValue[i] = val; |
|---|
| 849 | } |
|---|
| 850 | break; |
|---|
| 851 | } |
|---|
| 852 | case 4: |
|---|
| 853 | { |
|---|
| 854 | sei_read_code( pDecodedMessageOutputStream, 8, val, "camera_iso_speed_idc" ); sei.m_cameraIsoSpeedIdc = val; |
|---|
| 855 | if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO |
|---|
| 856 | { |
|---|
| 857 | sei_read_code( pDecodedMessageOutputStream, 32, val, "camera_iso_speed_value" ); sei.m_cameraIsoSpeedValue = val; |
|---|
| 858 | } |
|---|
| 859 | sei_read_code( pDecodedMessageOutputStream, 8, val, "exposure_index_idc" ); sei.m_exposureIndexIdc = val; |
|---|
| 860 | if( sei.m_exposureIndexIdc == 255) //Extended_ISO |
|---|
| 861 | { |
|---|
| 862 | sei_read_code( pDecodedMessageOutputStream, 32, val, "exposure_index_value" ); sei.m_exposureIndexValue = val; |
|---|
| 863 | } |
|---|
| 864 | sei_read_flag( pDecodedMessageOutputStream, val, "exposure_compensation_value_sign_flag" ); sei.m_exposureCompensationValueSignFlag = val; |
|---|
| 865 | sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_numerator" ); sei.m_exposureCompensationValueNumerator = val; |
|---|
| 866 | sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_denom_idc" ); sei.m_exposureCompensationValueDenomIdc = val; |
|---|
| 867 | sei_read_code( pDecodedMessageOutputStream, 32, val, "ref_screen_luminance_white" ); sei.m_refScreenLuminanceWhite = val; |
|---|
| 868 | sei_read_code( pDecodedMessageOutputStream, 32, val, "extended_range_white_level" ); sei.m_extendedRangeWhiteLevel = val; |
|---|
| 869 | sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_black_level_code_value" ); sei.m_nominalBlackLevelLumaCodeValue = val; |
|---|
| 870 | sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_white_level_code_value" ); sei.m_nominalWhiteLevelLumaCodeValue= val; |
|---|
| 871 | sei_read_code( pDecodedMessageOutputStream, 16, val, "extended_white_level_code_value" ); sei.m_extendedWhiteLevelLumaCodeValue = val; |
|---|
| 872 | break; |
|---|
| 873 | } |
|---|
| 874 | default: |
|---|
| 875 | { |
|---|
| 876 | assert(!"Undefined SEIToneMapModelId"); |
|---|
| 877 | break; |
|---|
| 878 | } |
|---|
| 879 | }//switch model id |
|---|
| 880 | }// if(!sei.m_toneMapCancelFlag) |
|---|
| 881 | } |
|---|
| 882 | |
|---|
| 883 | Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 884 | { |
|---|
| 885 | Int iCode; |
|---|
| 886 | UInt uiCode; |
|---|
| 887 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 888 | |
|---|
| 889 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "sop_seq_parameter_set_id" ); sei.m_sopSeqParameterSetId = uiCode; |
|---|
| 890 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_pics_in_sop_minus1" ); sei.m_numPicsInSopMinus1 = uiCode; |
|---|
| 891 | for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++) |
|---|
| 892 | { |
|---|
| 893 | sei_read_code( pDecodedMessageOutputStream, 6, uiCode, "sop_vcl_nut[i]" ); sei.m_sopDescVclNaluType[i] = uiCode; |
|---|
| 894 | sei_read_code( pDecodedMessageOutputStream, 3, sei.m_sopDescTemporalId[i], "sop_temporal_id[i]" ); sei.m_sopDescTemporalId[i] = uiCode; |
|---|
| 895 | if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP) |
|---|
| 896 | { |
|---|
| 897 | sei_read_uvlc( pDecodedMessageOutputStream, sei.m_sopDescStRpsIdx[i], "sop_short_term_rps_idx[i]" ); sei.m_sopDescStRpsIdx[i] = uiCode; |
|---|
| 898 | } |
|---|
| 899 | if (i > 0) |
|---|
| 900 | { |
|---|
| 901 | sei_read_svlc( pDecodedMessageOutputStream, iCode, "sop_poc_delta[i]" ); sei.m_sopDescPocDelta[i] = iCode; |
|---|
| 902 | } |
|---|
| 903 | } |
|---|
| 904 | } |
|---|
| 905 | |
|---|
| 906 | #if NH_MV |
|---|
| 907 | Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, const TComVPS *vps, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 908 | #else |
|---|
| 909 | Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 910 | #endif |
|---|
| 911 | { |
|---|
| 912 | UInt uiCode; |
|---|
| 913 | SEIMessages seis; |
|---|
| 914 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 915 | |
|---|
| 916 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "bitstream_subset_flag" ); sei.m_bitStreamSubsetFlag = uiCode; |
|---|
| 917 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "nesting_op_flag" ); sei.m_nestingOpFlag = uiCode; |
|---|
| 918 | if (sei.m_nestingOpFlag) |
|---|
| 919 | { |
|---|
| 920 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "default_op_flag" ); sei.m_defaultOpFlag = uiCode; |
|---|
| 921 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_num_ops_minus1" ); sei.m_nestingNumOpsMinus1 = uiCode; |
|---|
| 922 | for (UInt i = sei.m_defaultOpFlag; i <= sei.m_nestingNumOpsMinus1; i++) |
|---|
| 923 | { |
|---|
| 924 | sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "nesting_max_temporal_id_plus1[i]" ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode; |
|---|
| 925 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_op_idx[i]" ); sei.m_nestingOpIdx[i] = uiCode; |
|---|
| 926 | } |
|---|
| 927 | } |
|---|
| 928 | else |
|---|
| 929 | { |
|---|
| 930 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "all_layers_flag" ); sei.m_allLayersFlag = uiCode; |
|---|
| 931 | if (!sei.m_allLayersFlag) |
|---|
| 932 | { |
|---|
| 933 | sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "nesting_no_op_max_temporal_id_plus1" ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode; |
|---|
| 934 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_num_layers_minus1" ); sei.m_nestingNumLayersMinus1 = uiCode; |
|---|
| 935 | for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++) |
|---|
| 936 | { |
|---|
| 937 | sei_read_code( pDecodedMessageOutputStream, 6, uiCode, "nesting_layer_id[i]" ); sei.m_nestingLayerId[i] = uiCode; |
|---|
| 938 | } |
|---|
| 939 | } |
|---|
| 940 | } |
|---|
| 941 | |
|---|
| 942 | // byte alignment |
|---|
| 943 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
|---|
| 944 | { |
|---|
| 945 | UInt code; |
|---|
| 946 | sei_read_flag( pDecodedMessageOutputStream, code, "nesting_zero_bit" ); |
|---|
| 947 | } |
|---|
| 948 | |
|---|
| 949 | // read nested SEI messages |
|---|
| 950 | do |
|---|
| 951 | { |
|---|
| 952 | #if NH_MV |
|---|
| 953 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream); |
|---|
| 954 | #else |
|---|
| 955 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream); |
|---|
| 956 | #endif |
|---|
| 957 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
|---|
| 958 | |
|---|
| 959 | if (pDecodedMessageOutputStream) |
|---|
| 960 | { |
|---|
| 961 | (*pDecodedMessageOutputStream) << "End of scalable nesting SEI message\n"; |
|---|
| 962 | } |
|---|
| 963 | } |
|---|
| 964 | |
|---|
| 965 | |
|---|
| 966 | Void SEIReader::xParseSEITempMotionConstraintsTileSets(SEITempMotionConstrainedTileSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 967 | { |
|---|
| 968 | UInt code; |
|---|
| 969 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 970 | 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); |
|---|
| 971 | sei_read_flag( pDecodedMessageOutputStream, code, "each_tile_one_tile_set_flag"); sei.m_each_tile_one_tile_set_flag = (code != 0); |
|---|
| 972 | |
|---|
| 973 | if(!sei.m_each_tile_one_tile_set_flag) |
|---|
| 974 | { |
|---|
| 975 | sei_read_flag( pDecodedMessageOutputStream, code, "limited_tile_set_display_flag"); sei.m_limited_tile_set_display_flag = (code != 0); |
|---|
| 976 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_sets_in_message_minus1"); sei.setNumberOfTileSets(code + 1); |
|---|
| 977 | |
|---|
| 978 | if(sei.getNumberOfTileSets() != 0) |
|---|
| 979 | { |
|---|
| 980 | for(Int i = 0; i < sei.getNumberOfTileSets(); i++) |
|---|
| 981 | { |
|---|
| 982 | sei_read_uvlc( pDecodedMessageOutputStream, code, "mcts_id"); sei.tileSetData(i).m_mcts_id = code; |
|---|
| 983 | |
|---|
| 984 | if(sei.m_limited_tile_set_display_flag) |
|---|
| 985 | { |
|---|
| 986 | sei_read_flag( pDecodedMessageOutputStream, code, "display_tile_set_flag"); sei.tileSetData(i).m_display_tile_set_flag = (code != 1); |
|---|
| 987 | } |
|---|
| 988 | |
|---|
| 989 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_tile_rects_in_set_minus1"); sei.tileSetData(i).setNumberOfTileRects(code + 1); |
|---|
| 990 | |
|---|
| 991 | for(Int j=0; j<sei.tileSetData(i).getNumberOfTileRects(); j++) |
|---|
| 992 | { |
|---|
| 993 | sei_read_uvlc( pDecodedMessageOutputStream, code, "top_left_tile_index"); sei.tileSetData(i).topLeftTileIndex(j) = code; |
|---|
| 994 | sei_read_uvlc( pDecodedMessageOutputStream, code, "bottom_right_tile_index"); sei.tileSetData(i).bottomRightTileIndex(j) = code; |
|---|
| 995 | } |
|---|
| 996 | |
|---|
| 997 | if(!sei.m_mc_all_tiles_exact_sample_value_match_flag) |
|---|
| 998 | { |
|---|
| 999 | sei_read_flag( pDecodedMessageOutputStream, code, "exact_sample_value_match_flag"); sei.tileSetData(i).m_exact_sample_value_match_flag = (code != 0); |
|---|
| 1000 | } |
|---|
| 1001 | sei_read_flag( pDecodedMessageOutputStream, code, "mcts_tier_level_idc_present_flag"); sei.tileSetData(i).m_mcts_tier_level_idc_present_flag = (code != 0); |
|---|
| 1002 | |
|---|
| 1003 | if(sei.tileSetData(i).m_mcts_tier_level_idc_present_flag) |
|---|
| 1004 | { |
|---|
| 1005 | sei_read_flag( pDecodedMessageOutputStream, code, "mcts_tier_flag"); sei.tileSetData(i).m_mcts_tier_flag = (code != 0); |
|---|
| 1006 | sei_read_code( pDecodedMessageOutputStream, 8, code, "mcts_level_idc"); sei.tileSetData(i).m_mcts_level_idc = code; |
|---|
| 1007 | } |
|---|
| 1008 | } |
|---|
| 1009 | } |
|---|
| 1010 | } |
|---|
| 1011 | else |
|---|
| 1012 | { |
|---|
| 1013 | sei_read_flag( pDecodedMessageOutputStream, code, "max_mcs_tier_level_idc_present_flag"); sei.m_max_mcs_tier_level_idc_present_flag = code; |
|---|
| 1014 | if(sei.m_max_mcs_tier_level_idc_present_flag) |
|---|
| 1015 | { |
|---|
| 1016 | sei_read_flag( pDecodedMessageOutputStream, code, "max_mcts_tier_flag"); sei.m_max_mcts_tier_flag = code; |
|---|
| 1017 | sei_read_code( pDecodedMessageOutputStream, 8, code, "max_mcts_level_idc"); sei.m_max_mcts_level_idc = code; |
|---|
| 1018 | } |
|---|
| 1019 | } |
|---|
| 1020 | } |
|---|
| 1021 | |
|---|
| 1022 | Void SEIReader::xParseSEITimeCode(SEITimeCode& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1023 | { |
|---|
| 1024 | UInt code; |
|---|
| 1025 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1026 | sei_read_code( pDecodedMessageOutputStream, 2, code, "num_clock_ts"); sei.numClockTs = code; |
|---|
| 1027 | for(Int i = 0; i < sei.numClockTs; i++) |
|---|
| 1028 | { |
|---|
| 1029 | TComSEITimeSet currentTimeSet; |
|---|
| 1030 | sei_read_flag( pDecodedMessageOutputStream, code, "clock_time_stamp_flag[i]"); currentTimeSet.clockTimeStampFlag = code; |
|---|
| 1031 | if(currentTimeSet.clockTimeStampFlag) |
|---|
| 1032 | { |
|---|
| 1033 | sei_read_flag( pDecodedMessageOutputStream, code, "nuit_field_based_flag"); currentTimeSet.numUnitFieldBasedFlag = code; |
|---|
| 1034 | sei_read_code( pDecodedMessageOutputStream, 5, code, "counting_type"); currentTimeSet.countingType = code; |
|---|
| 1035 | sei_read_flag( pDecodedMessageOutputStream, code, "full_timestamp_flag"); currentTimeSet.fullTimeStampFlag = code; |
|---|
| 1036 | sei_read_flag( pDecodedMessageOutputStream, code, "discontinuity_flag"); currentTimeSet.discontinuityFlag = code; |
|---|
| 1037 | sei_read_flag( pDecodedMessageOutputStream, code, "cnt_dropped_flag"); currentTimeSet.cntDroppedFlag = code; |
|---|
| 1038 | sei_read_code( pDecodedMessageOutputStream, 9, code, "n_frames"); currentTimeSet.numberOfFrames = code; |
|---|
| 1039 | if(currentTimeSet.fullTimeStampFlag) |
|---|
| 1040 | { |
|---|
| 1041 | sei_read_code( pDecodedMessageOutputStream, 6, code, "seconds_value"); currentTimeSet.secondsValue = code; |
|---|
| 1042 | sei_read_code( pDecodedMessageOutputStream, 6, code, "minutes_value"); currentTimeSet.minutesValue = code; |
|---|
| 1043 | sei_read_code( pDecodedMessageOutputStream, 5, code, "hours_value"); currentTimeSet.hoursValue = code; |
|---|
| 1044 | } |
|---|
| 1045 | else |
|---|
| 1046 | { |
|---|
| 1047 | sei_read_flag( pDecodedMessageOutputStream, code, "seconds_flag"); currentTimeSet.secondsFlag = code; |
|---|
| 1048 | if(currentTimeSet.secondsFlag) |
|---|
| 1049 | { |
|---|
| 1050 | sei_read_code( pDecodedMessageOutputStream, 6, code, "seconds_value"); currentTimeSet.secondsValue = code; |
|---|
| 1051 | sei_read_flag( pDecodedMessageOutputStream, code, "minutes_flag"); currentTimeSet.minutesFlag = code; |
|---|
| 1052 | if(currentTimeSet.minutesFlag) |
|---|
| 1053 | { |
|---|
| 1054 | sei_read_code( pDecodedMessageOutputStream, 6, code, "minutes_value"); currentTimeSet.minutesValue = code; |
|---|
| 1055 | sei_read_flag( pDecodedMessageOutputStream, code, "hours_flag"); currentTimeSet.hoursFlag = code; |
|---|
| 1056 | if(currentTimeSet.hoursFlag) |
|---|
| 1057 | { |
|---|
| 1058 | sei_read_code( pDecodedMessageOutputStream, 5, code, "hours_value"); currentTimeSet.hoursValue = code; |
|---|
| 1059 | } |
|---|
| 1060 | } |
|---|
| 1061 | } |
|---|
| 1062 | } |
|---|
| 1063 | sei_read_code( pDecodedMessageOutputStream, 5, code, "time_offset_length"); currentTimeSet.timeOffsetLength = code; |
|---|
| 1064 | if(currentTimeSet.timeOffsetLength > 0) |
|---|
| 1065 | { |
|---|
| 1066 | sei_read_code( pDecodedMessageOutputStream, currentTimeSet.timeOffsetLength, code, "time_offset_value"); |
|---|
| 1067 | if((code & (1 << (currentTimeSet.timeOffsetLength-1))) == 0) |
|---|
| 1068 | { |
|---|
| 1069 | currentTimeSet.timeOffsetValue = code; |
|---|
| 1070 | } |
|---|
| 1071 | else |
|---|
| 1072 | { |
|---|
| 1073 | code &= (1<< (currentTimeSet.timeOffsetLength-1)) - 1; |
|---|
| 1074 | currentTimeSet.timeOffsetValue = ~code + 1; |
|---|
| 1075 | } |
|---|
| 1076 | } |
|---|
| 1077 | } |
|---|
| 1078 | sei.timeSetArray[i] = currentTimeSet; |
|---|
| 1079 | } |
|---|
| 1080 | } |
|---|
| 1081 | |
|---|
| 1082 | Void SEIReader::xParseSEIChromaResamplingFilterHint(SEIChromaResamplingFilterHint& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1083 | { |
|---|
| 1084 | UInt uiCode; |
|---|
| 1085 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1086 | |
|---|
| 1087 | sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "ver_chroma_filter_idc"); sei.m_verChromaFilterIdc = uiCode; |
|---|
| 1088 | sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "hor_chroma_filter_idc"); sei.m_horChromaFilterIdc = uiCode; |
|---|
| 1089 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "ver_filtering_field_processing_flag"); sei.m_verFilteringFieldProcessingFlag = uiCode; |
|---|
| 1090 | if(sei.m_verChromaFilterIdc == 1 || sei.m_horChromaFilterIdc == 1) |
|---|
| 1091 | { |
|---|
| 1092 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "target_format_idc"); sei.m_targetFormatIdc = uiCode; |
|---|
| 1093 | if(sei.m_verChromaFilterIdc == 1) |
|---|
| 1094 | { |
|---|
| 1095 | UInt numVerticalFilters; |
|---|
| 1096 | sei_read_uvlc( pDecodedMessageOutputStream, numVerticalFilters, "num_vertical_filters"); sei.m_verFilterCoeff.resize(numVerticalFilters); |
|---|
| 1097 | if(numVerticalFilters > 0) |
|---|
| 1098 | { |
|---|
| 1099 | for(Int i = 0; i < numVerticalFilters; i++) |
|---|
| 1100 | { |
|---|
| 1101 | UInt verTapLengthMinus1; |
|---|
| 1102 | sei_read_uvlc( pDecodedMessageOutputStream, verTapLengthMinus1, "ver_tap_length_minus_1"); sei.m_verFilterCoeff[i].resize(verTapLengthMinus1+1); |
|---|
| 1103 | for(Int j = 0; j < (verTapLengthMinus1 + 1); j++) |
|---|
| 1104 | { |
|---|
| 1105 | sei_read_svlc( pDecodedMessageOutputStream, sei.m_verFilterCoeff[i][j], "ver_filter_coeff"); |
|---|
| 1106 | } |
|---|
| 1107 | } |
|---|
| 1108 | } |
|---|
| 1109 | } |
|---|
| 1110 | if(sei.m_horChromaFilterIdc == 1) |
|---|
| 1111 | { |
|---|
| 1112 | UInt numHorizontalFilters; |
|---|
| 1113 | sei_read_uvlc( pDecodedMessageOutputStream, numHorizontalFilters, "num_horizontal_filters"); sei.m_horFilterCoeff.resize(numHorizontalFilters); |
|---|
| 1114 | if(numHorizontalFilters > 0) |
|---|
| 1115 | { |
|---|
| 1116 | for(Int i = 0; i < numHorizontalFilters; i++) |
|---|
| 1117 | { |
|---|
| 1118 | UInt horTapLengthMinus1; |
|---|
| 1119 | sei_read_uvlc( pDecodedMessageOutputStream, horTapLengthMinus1, "hor_tap_length_minus_1"); sei.m_horFilterCoeff[i].resize(horTapLengthMinus1+1); |
|---|
| 1120 | for(Int j = 0; j < (horTapLengthMinus1 + 1); j++) |
|---|
| 1121 | { |
|---|
| 1122 | sei_read_svlc( pDecodedMessageOutputStream, sei.m_horFilterCoeff[i][j], "hor_filter_coeff"); |
|---|
| 1123 | } |
|---|
| 1124 | } |
|---|
| 1125 | } |
|---|
| 1126 | } |
|---|
| 1127 | } |
|---|
| 1128 | } |
|---|
| 1129 | |
|---|
| 1130 | Void SEIReader::xParseSEIKneeFunctionInfo(SEIKneeFunctionInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1131 | { |
|---|
| 1132 | Int i; |
|---|
| 1133 | UInt val; |
|---|
| 1134 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1135 | |
|---|
| 1136 | sei_read_uvlc( pDecodedMessageOutputStream, val, "knee_function_id" ); sei.m_kneeId = val; |
|---|
| 1137 | sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_cancel_flag" ); sei.m_kneeCancelFlag = val; |
|---|
| 1138 | if ( !sei.m_kneeCancelFlag ) |
|---|
| 1139 | { |
|---|
| 1140 | sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_persistence_flag" ); sei.m_kneePersistenceFlag = val; |
|---|
| 1141 | sei_read_code( pDecodedMessageOutputStream, 32, val, "input_d_range" ); sei.m_kneeInputDrange = val; |
|---|
| 1142 | sei_read_code( pDecodedMessageOutputStream, 32, val, "input_disp_luminance" ); sei.m_kneeInputDispLuminance = val; |
|---|
| 1143 | sei_read_code( pDecodedMessageOutputStream, 32, val, "output_d_range" ); sei.m_kneeOutputDrange = val; |
|---|
| 1144 | sei_read_code( pDecodedMessageOutputStream, 32, val, "output_disp_luminance" ); sei.m_kneeOutputDispLuminance = val; |
|---|
| 1145 | sei_read_uvlc( pDecodedMessageOutputStream, val, "num_knee_points_minus1" ); sei.m_kneeNumKneePointsMinus1 = val; |
|---|
| 1146 | assert( sei.m_kneeNumKneePointsMinus1 > 0 ); |
|---|
| 1147 | sei.m_kneeInputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1); |
|---|
| 1148 | sei.m_kneeOutputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1); |
|---|
| 1149 | for(i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ ) |
|---|
| 1150 | { |
|---|
| 1151 | sei_read_code( pDecodedMessageOutputStream, 10, val, "input_knee_point" ); sei.m_kneeInputKneePoint[i] = val; |
|---|
| 1152 | sei_read_code( pDecodedMessageOutputStream, 10, val, "output_knee_point" ); sei.m_kneeOutputKneePoint[i] = val; |
|---|
| 1153 | } |
|---|
| 1154 | } |
|---|
| 1155 | } |
|---|
| 1156 | |
|---|
| 1157 | Void SEIReader::xParseSEIColourRemappingInfo(SEIColourRemappingInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1158 | { |
|---|
| 1159 | UInt uiVal; |
|---|
| 1160 | Int iVal; |
|---|
| 1161 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1162 | |
|---|
| 1163 | sei_read_uvlc( pDecodedMessageOutputStream, uiVal, "colour_remap_id" ); sei.m_colourRemapId = uiVal; |
|---|
| 1164 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_cancel_flag" ); sei.m_colourRemapCancelFlag = uiVal; |
|---|
| 1165 | if( !sei.m_colourRemapCancelFlag ) |
|---|
| 1166 | { |
|---|
| 1167 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_persistence_flag" ); sei.m_colourRemapPersistenceFlag = uiVal; |
|---|
| 1168 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_video_signal_info_present_flag" ); sei.m_colourRemapVideoSignalInfoPresentFlag = uiVal; |
|---|
| 1169 | if ( sei.m_colourRemapVideoSignalInfoPresentFlag ) |
|---|
| 1170 | { |
|---|
| 1171 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_full_range_flag" ); sei.m_colourRemapFullRangeFlag = uiVal; |
|---|
| 1172 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_primaries" ); sei.m_colourRemapPrimaries = uiVal; |
|---|
| 1173 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_transfer_function" ); sei.m_colourRemapTransferFunction = uiVal; |
|---|
| 1174 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_matrix_coefficients" ); sei.m_colourRemapMatrixCoefficients = uiVal; |
|---|
| 1175 | } |
|---|
| 1176 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_input_bit_depth" ); sei.m_colourRemapInputBitDepth = uiVal; |
|---|
| 1177 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_bit_depth" ); sei.m_colourRemapBitDepth = uiVal; |
|---|
| 1178 | |
|---|
| 1179 | for( Int c=0 ; c<3 ; c++ ) |
|---|
| 1180 | { |
|---|
| 1181 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "pre_lut_num_val_minus1[c]" ); sei.m_preLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; |
|---|
| 1182 | sei.m_preLut[c].resize(sei.m_preLutNumValMinus1[c]+1); |
|---|
| 1183 | if( uiVal> 0 ) |
|---|
| 1184 | { |
|---|
| 1185 | for ( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ ) |
|---|
| 1186 | { |
|---|
| 1187 | sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_coded_value[c][i]" ); sei.m_preLut[c][i].codedValue = uiVal; |
|---|
| 1188 | sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_target_value[c][i]" ); sei.m_preLut[c][i].targetValue = uiVal; |
|---|
| 1189 | } |
|---|
| 1190 | } |
|---|
| 1191 | else // pre_lut_num_val_minus1[c] == 0 |
|---|
| 1192 | { |
|---|
| 1193 | sei.m_preLut[c][0].codedValue = 0; |
|---|
| 1194 | sei.m_preLut[c][0].targetValue = 0; |
|---|
| 1195 | sei.m_preLut[c][1].codedValue = (1 << sei.m_colourRemapInputBitDepth) - 1 ; |
|---|
| 1196 | sei.m_preLut[c][1].targetValue = (1 << sei.m_colourRemapBitDepth) - 1 ; |
|---|
| 1197 | } |
|---|
| 1198 | } |
|---|
| 1199 | |
|---|
| 1200 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_matrix_present_flag" ); sei.m_colourRemapMatrixPresentFlag = uiVal; |
|---|
| 1201 | if( sei.m_colourRemapMatrixPresentFlag ) |
|---|
| 1202 | { |
|---|
| 1203 | sei_read_code( pDecodedMessageOutputStream, 4, uiVal, "log2_matrix_denom" ); sei.m_log2MatrixDenom = uiVal; |
|---|
| 1204 | for ( Int c=0 ; c<3 ; c++ ) |
|---|
| 1205 | { |
|---|
| 1206 | for ( Int i=0 ; i<3 ; i++ ) |
|---|
| 1207 | { |
|---|
| 1208 | sei_read_svlc( pDecodedMessageOutputStream, iVal, "colour_remap_coeffs[c][i]" ); sei.m_colourRemapCoeffs[c][i] = iVal; |
|---|
| 1209 | } |
|---|
| 1210 | } |
|---|
| 1211 | } |
|---|
| 1212 | else // setting default matrix (I3) |
|---|
| 1213 | { |
|---|
| 1214 | sei.m_log2MatrixDenom = 10; |
|---|
| 1215 | for ( Int c=0 ; c<3 ; c++ ) |
|---|
| 1216 | { |
|---|
| 1217 | for ( Int i=0 ; i<3 ; i++ ) |
|---|
| 1218 | { |
|---|
| 1219 | sei.m_colourRemapCoeffs[c][i] = (c==i) << sei.m_log2MatrixDenom; |
|---|
| 1220 | } |
|---|
| 1221 | } |
|---|
| 1222 | } |
|---|
| 1223 | for( Int c=0 ; c<3 ; c++ ) |
|---|
| 1224 | { |
|---|
| 1225 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "post_lut_num_val_minus1[c]" ); sei.m_postLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; |
|---|
| 1226 | sei.m_postLut[c].resize(sei.m_postLutNumValMinus1[c]+1); |
|---|
| 1227 | if( uiVal > 0 ) |
|---|
| 1228 | { |
|---|
| 1229 | for ( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ ) |
|---|
| 1230 | { |
|---|
| 1231 | sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_coded_value[c][i]" ); sei.m_postLut[c][i].codedValue = uiVal; |
|---|
| 1232 | sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_target_value[c][i]" ); sei.m_postLut[c][i].targetValue = uiVal; |
|---|
| 1233 | } |
|---|
| 1234 | } |
|---|
| 1235 | else |
|---|
| 1236 | { |
|---|
| 1237 | sei.m_postLut[c][0].codedValue = 0; |
|---|
| 1238 | sei.m_postLut[c][0].targetValue = 0; |
|---|
| 1239 | sei.m_postLut[c][1].targetValue = (1 << sei.m_colourRemapBitDepth) - 1; |
|---|
| 1240 | sei.m_postLut[c][1].codedValue = (1 << sei.m_colourRemapBitDepth) - 1; |
|---|
| 1241 | } |
|---|
| 1242 | } |
|---|
| 1243 | } |
|---|
| 1244 | } |
|---|
| 1245 | |
|---|
| 1246 | |
|---|
| 1247 | Void SEIReader::xParseSEIMasteringDisplayColourVolume(SEIMasteringDisplayColourVolume& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1248 | { |
|---|
| 1249 | UInt code; |
|---|
| 1250 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1251 | |
|---|
| 1252 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[0]" ); sei.values.primaries[0][0] = code; |
|---|
| 1253 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[0]" ); sei.values.primaries[0][1] = code; |
|---|
| 1254 | |
|---|
| 1255 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[1]" ); sei.values.primaries[1][0] = code; |
|---|
| 1256 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[1]" ); sei.values.primaries[1][1] = code; |
|---|
| 1257 | |
|---|
| 1258 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[2]" ); sei.values.primaries[2][0] = code; |
|---|
| 1259 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[2]" ); sei.values.primaries[2][1] = code; |
|---|
| 1260 | |
|---|
| 1261 | |
|---|
| 1262 | sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_x" ); sei.values.whitePoint[0] = code; |
|---|
| 1263 | sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_y" ); sei.values.whitePoint[1] = code; |
|---|
| 1264 | |
|---|
| 1265 | sei_read_code( pDecodedMessageOutputStream, 32, code, "max_display_mastering_luminance" ); sei.values.maxLuminance = code; |
|---|
| 1266 | sei_read_code( pDecodedMessageOutputStream, 32, code, "min_display_mastering_luminance" ); sei.values.minLuminance = code; |
|---|
| 1267 | } |
|---|
| 1268 | #if NH_MV |
|---|
| 1269 | Void SEIReader::xParseSEILayersNotPresent(SEILayersNotPresent &sei, UInt payloadSize, const TComVPS *vps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1270 | { |
|---|
| 1271 | UInt code; |
|---|
| 1272 | |
|---|
| 1273 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1274 | sei_read_code( pDecodedMessageOutputStream, 4, code, "lnp_sei_active_vps_id" ); sei.m_lnpSeiActiveVpsId = code; |
|---|
| 1275 | assert(vps->getVPSId() == sei.m_lnpSeiActiveVpsId); |
|---|
| 1276 | |
|---|
| 1277 | sei.m_lnpSeiMaxLayers = vps->getMaxLayersMinus1() + 1; |
|---|
| 1278 | sei.resizeDimI(sei.m_lnpSeiMaxLayers); |
|---|
| 1279 | for (Int i = 0; i < sei.m_lnpSeiMaxLayers; i++) |
|---|
| 1280 | { |
|---|
| 1281 | sei_read_flag( pDecodedMessageOutputStream, code, "layer_not_present_flag" ); |
|---|
| 1282 | sei.m_layerNotPresentFlag[i] = (code == 1); |
|---|
| 1283 | } |
|---|
| 1284 | }; |
|---|
| 1285 | |
|---|
| 1286 | Void SEIReader::xParseSEIInterLayerConstrainedTileSets(SEIInterLayerConstrainedTileSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1287 | { |
|---|
| 1288 | UInt code; |
|---|
| 1289 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1290 | |
|---|
| 1291 | sei_read_flag( pDecodedMessageOutputStream, code, "il_all_tiles_exact_sample_value_match_flag" ); sei.m_ilAllTilesExactSampleValueMatchFlag = (code == 1); |
|---|
| 1292 | sei_read_flag( pDecodedMessageOutputStream, code, "il_one_tile_per_tile_set_flag" ); sei.m_ilOneTilePerTileSetFlag = (code == 1); |
|---|
| 1293 | if( !sei.m_ilOneTilePerTileSetFlag ) |
|---|
| 1294 | { |
|---|
| 1295 | sei_read_uvlc( pDecodedMessageOutputStream, code, "il_num_sets_in_message_minus1" ); sei.m_ilNumSetsInMessageMinus1 = code; |
|---|
| 1296 | if( sei.m_ilNumSetsInMessageMinus1 ) |
|---|
| 1297 | { |
|---|
| 1298 | sei_read_flag( pDecodedMessageOutputStream, code, "skipped_tile_set_present_flag" ); sei.m_skippedTileSetPresentFlag = (code == 1); |
|---|
| 1299 | } |
|---|
| 1300 | Int numSignificantSets = sei.m_ilNumSetsInMessageMinus1 - sei.m_skippedTileSetPresentFlag + 1; |
|---|
| 1301 | |
|---|
| 1302 | sei.resizeDimI( numSignificantSets ); |
|---|
| 1303 | for( Int i = 0; i < numSignificantSets; i++ ) |
|---|
| 1304 | { |
|---|
| 1305 | sei_read_uvlc( pDecodedMessageOutputStream, code, "ilcts_id" ); sei.m_ilctsId [i] = code; |
|---|
| 1306 | sei_read_uvlc( pDecodedMessageOutputStream, code, "il_num_tile_rects_in_set_minus1" ); sei.m_ilNumTileRectsInSetMinus1[i] = code; |
|---|
| 1307 | |
|---|
| 1308 | sei.resizeDimJ( i, sei.m_ilNumTileRectsInSetMinus1[ i ] + 1 ); |
|---|
| 1309 | for( Int j = 0; j <= sei.m_ilNumTileRectsInSetMinus1[ i ]; j++ ) |
|---|
| 1310 | { |
|---|
| 1311 | sei_read_uvlc( pDecodedMessageOutputStream, code, "il_top_left_tile_index" ); sei.m_ilTopLeftTileIndex [i][j] = code; |
|---|
| 1312 | sei_read_uvlc( pDecodedMessageOutputStream, code, "il_bottom_right_tile_index" ); sei.m_ilBottomRightTileIndex[i][j] = code; |
|---|
| 1313 | } |
|---|
| 1314 | sei_read_code( pDecodedMessageOutputStream, 2, code, "ilc_idc" ); sei.m_ilcIdc[i] = code; |
|---|
| 1315 | if ( !sei.m_ilAllTilesExactSampleValueMatchFlag ) |
|---|
| 1316 | { |
|---|
| 1317 | sei_read_flag( pDecodedMessageOutputStream, code, "il_exact_sample_value_match_flag" ); sei.m_ilExactSampleValueMatchFlag[i] = (code == 1); |
|---|
| 1318 | } |
|---|
| 1319 | } |
|---|
| 1320 | } |
|---|
| 1321 | else |
|---|
| 1322 | { |
|---|
| 1323 | sei_read_code( pDecodedMessageOutputStream, 2, code, "all_tiles_ilc_idc" ); sei.m_allTilesIlcIdc = code; |
|---|
| 1324 | } |
|---|
| 1325 | }; |
|---|
| 1326 | |
|---|
| 1327 | #if NH_MV_SEI_TBD |
|---|
| 1328 | Void SEIReader::xParseSEIBspNesting(SEIBspNesting& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1329 | { |
|---|
| 1330 | UInt code; |
|---|
| 1331 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1332 | |
|---|
| 1333 | sei_read_uvlc( pDecodedMessageOutputStream, code, "sei_ols_idx" ); sei.m_seiOlsIdx = code; |
|---|
| 1334 | sei_read_uvlc( pDecodedMessageOutputStream, code, "sei_partitioning_scheme_idx" ); sei.m_seiPartitioningSchemeIdx = code; |
|---|
| 1335 | sei_read_uvlc( pDecodedMessageOutputStream, code, "bsp_idx" ); sei.m_bspIdx = code; |
|---|
| 1336 | while( !ByteaLigned(() ) ); |
|---|
| 1337 | { |
|---|
| 1338 | sei_read_code( pDecodedMessageOutputStream, *equalto0*/u1, code, "bsp_nesting_zero_bit" ); sei.m_bspNestingZeroBit = code; |
|---|
| 1339 | } |
|---|
| 1340 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_seis_in_bsp_minus1" ); sei.m_numSeisInBspMinus1 = code; |
|---|
| 1341 | for( Int i = 0; i <= NumSeisInBspMinus1( ); i++ ) |
|---|
| 1342 | { |
|---|
| 1343 | SeiMessage(() ); |
|---|
| 1344 | } |
|---|
| 1345 | }; |
|---|
| 1346 | |
|---|
| 1347 | Void SEIReader::xParseSEIBspInitialArrivalTime(SEIBspInitialArrivalTime& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1348 | { |
|---|
| 1349 | UInt code; |
|---|
| 1350 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1351 | |
|---|
| 1352 | psIdx = SeiPartitioningSchemeIdx(); |
|---|
| 1353 | if( nalInitialArrivalDelayPresent ) |
|---|
| 1354 | { |
|---|
| 1355 | for( Int i = 0; i < BspSchedCnt( SeiOlsIdx(), psIdx, MaxTemporalId( 0 ) ); i++ ) |
|---|
| 1356 | { |
|---|
| 1357 | sei_read_code( pDecodedMessageOutputStream, getNalInitialArrivalDelayLen ), code, "nal_initial_arrival_delay" ); sei.m_nalInitialArrivalDelay[i] = code; |
|---|
| 1358 | } |
|---|
| 1359 | } |
|---|
| 1360 | if( vclInitialArrivalDelayPresent ) |
|---|
| 1361 | { |
|---|
| 1362 | for( Int i = 0; i < BspSchedCnt( SeiOlsIdx(), psIdx, MaxTemporalId( 0 ) ); i++ ) |
|---|
| 1363 | { |
|---|
| 1364 | sei_read_code( pDecodedMessageOutputStream, getVclInitialArrivalDelayLen ), code, "vcl_initial_arrival_delay" ); sei.m_vclInitialArrivalDelay[i] = code; |
|---|
| 1365 | } |
|---|
| 1366 | } |
|---|
| 1367 | }; |
|---|
| 1368 | #endif |
|---|
| 1369 | |
|---|
| 1370 | Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1371 | { |
|---|
| 1372 | UInt code; |
|---|
| 1373 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1374 | |
|---|
| 1375 | sei_read_code( pDecodedMessageOutputStream, 4, code, "sb_property_active_vps_id" ); sei.m_sbPropertyActiveVpsId = code; |
|---|
| 1376 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_additional_sub_streams_minus1" ); sei.m_numAdditionalSubStreamsMinus1 = code; |
|---|
| 1377 | sei.resizeArrays( ); |
|---|
| 1378 | for( Int i = 0; i <= sei.m_numAdditionalSubStreamsMinus1; i++ ) |
|---|
| 1379 | { |
|---|
| 1380 | sei_read_code( pDecodedMessageOutputStream, 2, code, "sub_bitstream_mode" ); sei.m_subBitstreamMode[i] = code; |
|---|
| 1381 | sei_read_uvlc( pDecodedMessageOutputStream, code, "ols_idx_to_vps" ); sei.m_olsIdxToVps[i] = code; |
|---|
| 1382 | sei_read_code( pDecodedMessageOutputStream, 3, code, "highest_sublayer_id" ); sei.m_highestSublayerId[i] = code; |
|---|
| 1383 | sei_read_code( pDecodedMessageOutputStream, 16, code, "avg_sb_property_bit_rate" ); sei.m_avgSbPropertyBitRate[i] = code; |
|---|
| 1384 | sei_read_code( pDecodedMessageOutputStream, 16, code, "max_sb_property_bit_rate" ); sei.m_maxSbPropertyBitRate[i] = code; |
|---|
| 1385 | } |
|---|
| 1386 | }; |
|---|
| 1387 | |
|---|
| 1388 | Void SEIReader::xParseSEIAlphaChannelInfo(SEIAlphaChannelInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1389 | { |
|---|
| 1390 | UInt code; |
|---|
| 1391 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1392 | |
|---|
| 1393 | sei_read_flag( pDecodedMessageOutputStream, code, "alpha_channel_cancel_flag" ); sei.m_alphaChannelCancelFlag = (code == 1); |
|---|
| 1394 | if( !sei.m_alphaChannelCancelFlag ) |
|---|
| 1395 | { |
|---|
| 1396 | sei_read_code( pDecodedMessageOutputStream, 3, code, "alpha_channel_use_idc" ); sei.m_alphaChannelUseIdc = code; |
|---|
| 1397 | sei_read_code( pDecodedMessageOutputStream, 3, code, "alpha_channel_bit_depth_minus8" ); sei.m_alphaChannelBitDepthMinus8 = code; |
|---|
| 1398 | sei_read_code( pDecodedMessageOutputStream, sei.m_alphaChannelBitDepthMinus8+9, code, "alpha_transparent_value" ); sei.m_alphaTransparentValue = code; |
|---|
| 1399 | sei_read_code( pDecodedMessageOutputStream, sei.m_alphaChannelBitDepthMinus8+9, code, "alpha_opaque_value" ); sei.m_alphaOpaqueValue = code; |
|---|
| 1400 | sei_read_flag( pDecodedMessageOutputStream, code, "alpha_channel_incr_flag" ); sei.m_alphaChannelIncrFlag = (code == 1); |
|---|
| 1401 | sei_read_flag( pDecodedMessageOutputStream, code, "alpha_channel_clip_flag" ); sei.m_alphaChannelClipFlag = (code == 1); |
|---|
| 1402 | if( sei.m_alphaChannelClipFlag ) |
|---|
| 1403 | { |
|---|
| 1404 | sei_read_flag( pDecodedMessageOutputStream, code, "alpha_channel_clip_type_flag" ); sei.m_alphaChannelClipTypeFlag = (code == 1); |
|---|
| 1405 | } |
|---|
| 1406 | } |
|---|
| 1407 | }; |
|---|
| 1408 | |
|---|
| 1409 | Void SEIReader::xParseSEIOverlayInfo(SEIOverlayInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1410 | { |
|---|
| 1411 | UInt code; |
|---|
| 1412 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1413 | |
|---|
| 1414 | sei_read_flag( pDecodedMessageOutputStream, code, "overlay_info_cancel_flag" ); sei.m_overlayInfoCancelFlag = (code == 1); |
|---|
| 1415 | if( !sei.m_overlayInfoCancelFlag ) |
|---|
| 1416 | { |
|---|
| 1417 | sei_read_uvlc( pDecodedMessageOutputStream, code, "overlay_content_aux_id_minus128" ); sei.m_overlayContentAuxIdMinus128 = code; |
|---|
| 1418 | sei_read_uvlc( pDecodedMessageOutputStream, code, "overlay_label_aux_id_minus128" ); sei.m_overlayLabelAuxIdMinus128 = code; |
|---|
| 1419 | sei_read_uvlc( pDecodedMessageOutputStream, code, "overlay_alpha_aux_id_minus128" ); sei.m_overlayAlphaAuxIdMinus128 = code; |
|---|
| 1420 | sei_read_uvlc( pDecodedMessageOutputStream, code, "overlay_element_label_value_length_minus8" ); sei.m_overlayElementLabelValueLengthMinus8 = code; |
|---|
| 1421 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_overlays_minus1" ); sei.m_numOverlaysMinus1 = code; |
|---|
| 1422 | |
|---|
| 1423 | sei.m_overlayIdx.resize( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1424 | sei.m_languageOverlayPresentFlag.resize( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1425 | sei.m_overlayContentLayerId.resize ( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1426 | sei.m_overlayLabelPresentFlag.resize ( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1427 | sei.m_overlayLabelLayerId.resize ( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1428 | sei.m_overlayAlphaPresentFlag.resize ( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1429 | sei.m_overlayAlphaLayerId.resize ( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1430 | sei.m_numOverlayElementsMinus1.resize ( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1431 | sei.m_overlayElementLabelMin.resize ( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1432 | sei.m_overlayElementLabelMax.resize ( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1433 | for( Int i = 0; i <= sei.m_numOverlaysMinus1; i++ ) |
|---|
| 1434 | { |
|---|
| 1435 | sei_read_uvlc( pDecodedMessageOutputStream, code, "overlay_idx" ); sei.m_overlayIdx[i] = code; |
|---|
| 1436 | sei_read_flag( pDecodedMessageOutputStream, code, "language_overlay_present_flag" ); sei.m_languageOverlayPresentFlag[i] = (code == 1); |
|---|
| 1437 | sei_read_code( pDecodedMessageOutputStream, 6, code, "overlay_content_layer_id" ); sei.m_overlayContentLayerId[i] = code; |
|---|
| 1438 | sei_read_flag( pDecodedMessageOutputStream, code, "overlay_label_present_flag" ); sei.m_overlayLabelPresentFlag[i] = (code == 1); |
|---|
| 1439 | if( sei.m_overlayLabelPresentFlag[i] ) |
|---|
| 1440 | { |
|---|
| 1441 | sei_read_code( pDecodedMessageOutputStream, 6, code, "overlay_label_layer_id" ); sei.m_overlayLabelLayerId[i] = code; |
|---|
| 1442 | } |
|---|
| 1443 | sei_read_flag( pDecodedMessageOutputStream, code, "overlay_alpha_present_flag" ); sei.m_overlayAlphaPresentFlag[i] = (code == 1); |
|---|
| 1444 | if( sei.m_overlayAlphaPresentFlag[i] ) |
|---|
| 1445 | { |
|---|
| 1446 | sei_read_code( pDecodedMessageOutputStream, 6, code, "overlay_alpha_layer_id" ); sei.m_overlayAlphaLayerId[i] = code; |
|---|
| 1447 | } |
|---|
| 1448 | if( sei.m_overlayLabelPresentFlag[i] ) |
|---|
| 1449 | { |
|---|
| 1450 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_overlay_elements_minus1" ); sei.m_numOverlayElementsMinus1[i] = code; |
|---|
| 1451 | sei.m_overlayElementLabelMin[i].resize( sei.m_numOverlayElementsMinus1[i]+1 ); |
|---|
| 1452 | sei.m_overlayElementLabelMax[i].resize( sei.m_numOverlayElementsMinus1[i]+1 ); |
|---|
| 1453 | for( Int j = 0; j <= sei.m_numOverlayElementsMinus1[i]; j++ ) |
|---|
| 1454 | { |
|---|
| 1455 | sei_read_code( pDecodedMessageOutputStream, sei.m_overlayElementLabelValueLengthMinus8 + 8, code, "overlay_element_label_min" ); sei.m_overlayElementLabelMin[i][j] = code; |
|---|
| 1456 | sei_read_code( pDecodedMessageOutputStream, sei.m_overlayElementLabelValueLengthMinus8 + 8, code, "overlay_element_label_max" ); sei.m_overlayElementLabelMax[i][j] = code; |
|---|
| 1457 | } |
|---|
| 1458 | } |
|---|
| 1459 | } |
|---|
| 1460 | |
|---|
| 1461 | // byte alignment |
|---|
| 1462 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
|---|
| 1463 | { |
|---|
| 1464 | sei_read_flag( pDecodedMessageOutputStream, code, "overlay_zero_bit" ); |
|---|
| 1465 | assert( code==0 ); |
|---|
| 1466 | } |
|---|
| 1467 | |
|---|
| 1468 | UChar* sval = new UChar[sei.m_numStringBytesMax]; |
|---|
| 1469 | UInt slen; |
|---|
| 1470 | sei.m_overlayLanguage .resize( sei.m_numOverlaysMinus1 + 1 ); |
|---|
| 1471 | sei.m_overlayName .resize( sei.m_numOverlaysMinus1 + 1 ); |
|---|
| 1472 | sei.m_overlayElementName.resize( sei.m_numOverlaysMinus1 + 1 ); |
|---|
| 1473 | for( Int i = 0; i <= sei.m_numOverlaysMinus1; i++ ) |
|---|
| 1474 | { |
|---|
| 1475 | if( sei.m_languageOverlayPresentFlag[i] ) |
|---|
| 1476 | { |
|---|
| 1477 | sei_read_string(pDecodedMessageOutputStream, sei.m_numStringBytesMax, sval, slen, "overlay_language"); |
|---|
| 1478 | sei.m_overlayLanguage[i] = std::string((const char*) sval); |
|---|
| 1479 | } |
|---|
| 1480 | sei_read_string(pDecodedMessageOutputStream, sei.m_numStringBytesMax, sval, slen, "overlay_name"); |
|---|
| 1481 | sei.m_overlayName[i] = std::string((const char*) sval); |
|---|
| 1482 | if( sei.m_overlayLabelPresentFlag[i] ) |
|---|
| 1483 | { |
|---|
| 1484 | sei.m_overlayElementName[i].resize( sei.m_numOverlayElementsMinus1[i]+1 ); |
|---|
| 1485 | for( Int j = 0; j <= sei.m_numOverlayElementsMinus1[i]; j++ ) |
|---|
| 1486 | { |
|---|
| 1487 | sei_read_string(pDecodedMessageOutputStream, sei.m_numStringBytesMax, sval, slen, "overlay_element_name"); |
|---|
| 1488 | sei.m_overlayElementName[i][j] = std::string((const char*) sval); |
|---|
| 1489 | } |
|---|
| 1490 | } |
|---|
| 1491 | } |
|---|
| 1492 | delete [] sval; |
|---|
| 1493 | sei_read_flag( pDecodedMessageOutputStream, code, "overlay_info_persistence_flag" ); sei.m_overlayInfoPersistenceFlag = (code == 1); |
|---|
| 1494 | } |
|---|
| 1495 | }; |
|---|
| 1496 | |
|---|
| 1497 | Void SEIReader::xParseSEITemporalMvPredictionConstraints(SEITemporalMvPredictionConstraints& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1498 | { |
|---|
| 1499 | UInt code; |
|---|
| 1500 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1501 | |
|---|
| 1502 | sei_read_flag( pDecodedMessageOutputStream, code, "prev_pics_not_used_flag" ); sei.m_prevPicsNotUsedFlag = (code == 1); |
|---|
| 1503 | sei_read_flag( pDecodedMessageOutputStream, code, "no_intra_layer_col_pic_flag" ); sei.m_noIntraLayerColPicFlag = (code == 1); |
|---|
| 1504 | }; |
|---|
| 1505 | |
|---|
| 1506 | #if NH_MV_SEI_TBD |
|---|
| 1507 | Void SEIReader::xParseSEIFrameFieldInfo(SEIFrameFieldInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1508 | { |
|---|
| 1509 | UInt code; |
|---|
| 1510 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1511 | |
|---|
| 1512 | sei_read_code( pDecodedMessageOutputStream, 4, code, "ffinfo_pic_struct" ); sei.m_ffinfoPicStruct = code; |
|---|
| 1513 | sei_read_code( pDecodedMessageOutputStream, 2, code, "ffinfo_source_scan_type" ); sei.m_ffinfoSourceScanType = code; |
|---|
| 1514 | sei_read_flag( pDecodedMessageOutputStream, code, "ffinfo_duplicate_flag" ); sei.m_ffinfoDuplicateFlag = (code == 1); |
|---|
| 1515 | }; |
|---|
| 1516 | #endif |
|---|
| 1517 | |
|---|
| 1518 | Void SEIReader::xParseSEIThreeDimensionalReferenceDisplaysInfo(SEIThreeDimensionalReferenceDisplaysInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1519 | { |
|---|
| 1520 | UInt code; |
|---|
| 1521 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1522 | |
|---|
| 1523 | sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_ref_display_width" ); sei.m_precRefDisplayWidth = code; |
|---|
| 1524 | sei_read_flag( pDecodedMessageOutputStream, code, "ref_viewing_distance_flag" ); sei.m_refViewingDistanceFlag = (code == 1); |
|---|
| 1525 | if( sei.m_refViewingDistanceFlag ) |
|---|
| 1526 | { |
|---|
| 1527 | sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_ref_viewing_dist" ); sei.m_precRefViewingDist = code; |
|---|
| 1528 | } |
|---|
| 1529 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_ref_displays_minus1" ); sei.m_numRefDisplaysMinus1 = code; |
|---|
| 1530 | sei.resizeArrays( ); |
|---|
| 1531 | for( Int i = 0; i <= sei.getNumRefDisplaysMinus1( ); i++ ) |
|---|
| 1532 | { |
|---|
| 1533 | sei_read_uvlc( pDecodedMessageOutputStream, code, "left_view_id" ); sei.m_leftViewId[i] = code; |
|---|
| 1534 | sei_read_uvlc( pDecodedMessageOutputStream, code, "right_view_id" ); sei.m_rightViewId[i] = code; |
|---|
| 1535 | sei_read_code( pDecodedMessageOutputStream, 6, code, "exponent_ref_display_width" ); sei.m_exponentRefDisplayWidth[i] = code; |
|---|
| 1536 | sei_read_code( pDecodedMessageOutputStream, sei.getMantissaReferenceDisplayWidthLen(i), code, "mantissa_ref_display_width" ); sei.m_mantissaRefDisplayWidth[i] = code ; |
|---|
| 1537 | if( sei.m_refViewingDistanceFlag ) |
|---|
| 1538 | { |
|---|
| 1539 | sei_read_code( pDecodedMessageOutputStream, 6, code, "exponent_ref_viewing_distance" ); sei.m_exponentRefViewingDistance[i] = code; |
|---|
| 1540 | sei_read_code( pDecodedMessageOutputStream, sei.getMantissaReferenceViewingDistanceLen(i), code, "mantissa_ref_viewing_distance" ); sei.m_mantissaRefViewingDistance[i] = code; |
|---|
| 1541 | } |
|---|
| 1542 | sei_read_flag( pDecodedMessageOutputStream, code, "additional_shift_present_flag" ); sei.m_additionalShiftPresentFlag[i] = (code == 1); |
|---|
| 1543 | if( sei.m_additionalShiftPresentFlag[i] ) |
|---|
| 1544 | { |
|---|
| 1545 | sei_read_code( pDecodedMessageOutputStream, 10, code, "num_sample_shift_plus512" ); sei.m_numSampleShiftPlus512[i] = code; |
|---|
| 1546 | } |
|---|
| 1547 | } |
|---|
| 1548 | sei_read_flag( pDecodedMessageOutputStream, code, "three_dimensional_reference_displays_extension_flag" ); sei.m_threeDimensionalReferenceDisplaysExtensionFlag = (code == 1); |
|---|
| 1549 | }; |
|---|
| 1550 | |
|---|
| 1551 | Void SEIReader::xParseSEIDepthRepInfoElement(double& f,std::ostream *pDecodedMessageOutputStream) |
|---|
| 1552 | { |
|---|
| 1553 | UInt val; |
|---|
| 1554 | UInt x_sign,x_mantissa_len,x_mantissa; |
|---|
| 1555 | Int x_exp; |
|---|
| 1556 | |
|---|
| 1557 | sei_read_flag(pDecodedMessageOutputStream, val,"da_sign_flag"); x_sign = val ? 1 : 0 ; |
|---|
| 1558 | sei_read_code(pDecodedMessageOutputStream, 7, val, "da_exponent" ); x_exp = val-31; |
|---|
| 1559 | sei_read_code(pDecodedMessageOutputStream, 5, val, "da_mantissa_len_minus1" ); x_mantissa_len = val+1; |
|---|
| 1560 | sei_read_code(pDecodedMessageOutputStream, x_mantissa_len, val, "da_mantissa" ); x_mantissa = val; |
|---|
| 1561 | if (x_mantissa_len>=16) |
|---|
| 1562 | { |
|---|
| 1563 | f =1.0 + (x_mantissa*1.0)/(1u<<(x_mantissa_len-16))/(256.0*256.0 ); |
|---|
| 1564 | }else |
|---|
| 1565 | { |
|---|
| 1566 | f =1.0 + (x_mantissa*1.0)/(1u<<x_mantissa_len); |
|---|
| 1567 | } |
|---|
| 1568 | double m=1.0; |
|---|
| 1569 | int i; |
|---|
| 1570 | if (x_exp<0) |
|---|
| 1571 | { |
|---|
| 1572 | for(i=0;i<-x_exp;i++) |
|---|
| 1573 | m = m * 2; |
|---|
| 1574 | |
|---|
| 1575 | f = f/m; |
|---|
| 1576 | } |
|---|
| 1577 | else |
|---|
| 1578 | { |
|---|
| 1579 | for(i=0;i<x_exp;i++) |
|---|
| 1580 | m = m * 2; |
|---|
| 1581 | |
|---|
| 1582 | f= f * m; |
|---|
| 1583 | } |
|---|
| 1584 | if (x_sign==1) |
|---|
| 1585 | { |
|---|
| 1586 | f= -f; |
|---|
| 1587 | } |
|---|
| 1588 | }; |
|---|
| 1589 | |
|---|
| 1590 | Void SEIReader::xParseSEIDepthRepresentationInfo(SEIDepthRepresentationInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1591 | { |
|---|
| 1592 | UInt code; |
|---|
| 1593 | double zNear,zFar,dMin,dMax; |
|---|
| 1594 | bool zNearFlag,zFarFlag,dMinFlag,dMaxFlag; |
|---|
| 1595 | int depth_representation_type,disparityRefViewId,depthNonlinearRepresentationNumMinus1; |
|---|
| 1596 | std::vector<int> DepthNonlinearRepresentationModel; |
|---|
| 1597 | |
|---|
| 1598 | sei.clear(); |
|---|
| 1599 | |
|---|
| 1600 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1601 | |
|---|
| 1602 | sei_read_flag( pDecodedMessageOutputStream, code, "z_near_flag" ); zNearFlag = (code == 1); |
|---|
| 1603 | sei_read_flag( pDecodedMessageOutputStream, code, "z_far_flag" ); zFarFlag = (code == 1); |
|---|
| 1604 | sei_read_flag( pDecodedMessageOutputStream, code, "d_min_flag" ); dMinFlag = (code == 1); |
|---|
| 1605 | sei_read_flag( pDecodedMessageOutputStream, code, "d_max_flag" ); dMaxFlag = (code == 1); |
|---|
| 1606 | sei_read_uvlc( pDecodedMessageOutputStream, code, "depth_representation_type" ); depth_representation_type = code; |
|---|
| 1607 | |
|---|
| 1608 | sei.m_zNearFlag.push_back(zNearFlag); |
|---|
| 1609 | sei.m_zFarFlag.push_back(zFarFlag); |
|---|
| 1610 | sei.m_dMinFlag.push_back(dMinFlag); |
|---|
| 1611 | sei.m_dMaxFlag.push_back(dMaxFlag); |
|---|
| 1612 | |
|---|
| 1613 | sei.m_depthRepresentationType.push_back(IntAry1d(1,depth_representation_type)); |
|---|
| 1614 | |
|---|
| 1615 | if( dMinFlag || dMaxFlag ) |
|---|
| 1616 | { |
|---|
| 1617 | sei_read_uvlc( pDecodedMessageOutputStream, code, "disparity_ref_view_id" ); disparityRefViewId = code; |
|---|
| 1618 | sei.m_disparityRefViewId.push_back(IntAry1d(1,disparityRefViewId)); |
|---|
| 1619 | } |
|---|
| 1620 | if( zNearFlag ) |
|---|
| 1621 | { |
|---|
| 1622 | xParseSEIDepthRepInfoElement(zNear , pDecodedMessageOutputStream); |
|---|
| 1623 | sei.m_zNear.push_back(std::vector<double>(1,zNear)); |
|---|
| 1624 | } |
|---|
| 1625 | if( zFarFlag ) |
|---|
| 1626 | { |
|---|
| 1627 | xParseSEIDepthRepInfoElement(zFar , pDecodedMessageOutputStream); |
|---|
| 1628 | sei.m_zFar.push_back(std::vector<double>(1,zFar)); |
|---|
| 1629 | } |
|---|
| 1630 | if( dMinFlag ) |
|---|
| 1631 | { |
|---|
| 1632 | xParseSEIDepthRepInfoElement(dMin , pDecodedMessageOutputStream); |
|---|
| 1633 | sei.m_dMin.push_back(std::vector<double>(1,dMin)); |
|---|
| 1634 | } |
|---|
| 1635 | if( dMaxFlag ) |
|---|
| 1636 | { |
|---|
| 1637 | xParseSEIDepthRepInfoElement(dMax , pDecodedMessageOutputStream); |
|---|
| 1638 | sei.m_dMax.push_back(std::vector<double>(1,dMax)); |
|---|
| 1639 | } |
|---|
| 1640 | if( depth_representation_type == 3 ) |
|---|
| 1641 | { |
|---|
| 1642 | sei_read_uvlc( pDecodedMessageOutputStream, code, "depth_nonlinear_representation_num_minus1" ); depthNonlinearRepresentationNumMinus1 = code; |
|---|
| 1643 | sei.m_depthNonlinearRepresentationNumMinus1.push_back(IntAry1d(1,depthNonlinearRepresentationNumMinus1)); |
|---|
| 1644 | for( Int i = 1; i <= depthNonlinearRepresentationNumMinus1 + 1; i++ ) |
|---|
| 1645 | { |
|---|
| 1646 | sei_read_uvlc(pDecodedMessageOutputStream,code,"DepthNonlinearRepresentationModel" ) ; |
|---|
| 1647 | DepthNonlinearRepresentationModel.push_back(code); |
|---|
| 1648 | } |
|---|
| 1649 | |
|---|
| 1650 | sei.m_depth_nonlinear_representation_model.push_back(DepthNonlinearRepresentationModel); |
|---|
| 1651 | } |
|---|
| 1652 | } |
|---|
| 1653 | |
|---|
| 1654 | Void SEIReader::xParseSEIMultiviewSceneInfo(SEIMultiviewSceneInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1655 | { |
|---|
| 1656 | UInt code; |
|---|
| 1657 | Int sCode; |
|---|
| 1658 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1659 | |
|---|
| 1660 | sei_read_svlc( pDecodedMessageOutputStream, sCode, "min_disparity" ) ; sei.m_minDisparity = sCode; |
|---|
| 1661 | sei_read_uvlc( pDecodedMessageOutputStream, code , "max_disparity_range" ); sei.m_maxDisparityRange = code; |
|---|
| 1662 | }; |
|---|
| 1663 | |
|---|
| 1664 | Void SEIReader::xParseSEIMultiviewAcquisitionInfo(SEIMultiviewAcquisitionInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1665 | { |
|---|
| 1666 | UInt code; |
|---|
| 1667 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1668 | |
|---|
| 1669 | sei.resizeArrays( ); |
|---|
| 1670 | sei_read_flag( pDecodedMessageOutputStream, code, "intrinsic_param_flag" ); sei.m_intrinsicParamFlag = (code == 1); |
|---|
| 1671 | sei_read_flag( pDecodedMessageOutputStream, code, "extrinsic_param_flag" ); sei.m_extrinsicParamFlag = (code == 1); |
|---|
| 1672 | if( sei.m_intrinsicParamFlag ) |
|---|
| 1673 | { |
|---|
| 1674 | sei_read_flag( pDecodedMessageOutputStream, code, "intrinsic_params_equal_flag" ); sei.m_intrinsicParamsEqualFlag = (code == 1); |
|---|
| 1675 | sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_focal_length" ); sei.m_precFocalLength = code ; |
|---|
| 1676 | sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_principal_point" ); sei.m_precPrincipalPoint = code ; |
|---|
| 1677 | sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_skew_factor" ); sei.m_precSkewFactor = code ; |
|---|
| 1678 | |
|---|
| 1679 | for( Int i = 0; i <= ( sei.m_intrinsicParamsEqualFlag ? 0 : sei.getNumViewsMinus1() ); i++ ) |
|---|
| 1680 | { |
|---|
| 1681 | sei_read_flag( pDecodedMessageOutputStream, code, "sign_focal_length_x" ); sei.m_signFocalLengthX [i] = (code == 1); |
|---|
| 1682 | sei_read_code( pDecodedMessageOutputStream, 6, code, "exponent_focal_length_x" ); sei.m_exponentFocalLengthX [i] = code ; |
|---|
| 1683 | sei_read_code( pDecodedMessageOutputStream, sei.getMantissaFocalLengthXLen ( i ), code, "mantissa_focal_length_x" ); sei.m_mantissaFocalLengthX [i] = code ; |
|---|
| 1684 | sei_read_flag( pDecodedMessageOutputStream, code, "sign_focal_length_y" ); sei.m_signFocalLengthY [i] = (code == 1); |
|---|
| 1685 | sei_read_code( pDecodedMessageOutputStream, 6, code, "exponent_focal_length_y" ); sei.m_exponentFocalLengthY [i] = code ; |
|---|
| 1686 | sei_read_code( pDecodedMessageOutputStream, sei.getMantissaFocalLengthYLen ( i ), code, "mantissa_focal_length_y" ); sei.m_mantissaFocalLengthY [i] = code ; |
|---|
| 1687 | sei_read_flag( pDecodedMessageOutputStream, code, "sign_principal_point_x" ); sei.m_signPrincipalPointX [i] = (code == 1); |
|---|
| 1688 | sei_read_code( pDecodedMessageOutputStream, 6, code, "exponent_principal_point_x" ); sei.m_exponentPrincipalPointX[i] = code ; |
|---|
| 1689 | sei_read_code( pDecodedMessageOutputStream, sei.getMantissaPrincipalPointXLen( i ), code, "mantissa_principal_point_x" ); sei.m_mantissaPrincipalPointX[i] = code ; |
|---|
| 1690 | sei_read_flag( pDecodedMessageOutputStream, code, "sign_principal_point_y" ); sei.m_signPrincipalPointY [i] = (code == 1); |
|---|
| 1691 | sei_read_code( pDecodedMessageOutputStream, 6, code, "exponent_principal_point_y" ); sei.m_exponentPrincipalPointY[i] = code ; |
|---|
| 1692 | sei_read_code( pDecodedMessageOutputStream, sei.getMantissaPrincipalPointYLen( i ), code, "mantissa_principal_point_y" ); sei.m_mantissaPrincipalPointY[i] = code ; |
|---|
| 1693 | sei_read_flag( pDecodedMessageOutputStream, code, "sign_skew_factor" ); sei.m_signSkewFactor [i] = (code == 1); |
|---|
| 1694 | sei_read_code( pDecodedMessageOutputStream, 6, code, "exponent_skew_factor" ); sei.m_exponentSkewFactor [i] = code ; |
|---|
| 1695 | sei_read_code( pDecodedMessageOutputStream, sei.getMantissaSkewFactorLen ( i ), code, "mantissa_skew_factor" ); sei.m_mantissaSkewFactor [i] = code ; |
|---|
| 1696 | } |
|---|
| 1697 | } |
|---|
| 1698 | if( sei.m_extrinsicParamFlag ) |
|---|
| 1699 | { |
|---|
| 1700 | sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_rotation_param" ); sei.m_precRotationParam = code; |
|---|
| 1701 | sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_translation_param" ); sei.m_precTranslationParam = code; |
|---|
| 1702 | |
|---|
| 1703 | for( Int i = 0; i <= sei.getNumViewsMinus1(); i++ ) |
|---|
| 1704 | { |
|---|
| 1705 | for( Int j = 0; j <= 2; j++ ) /* row */ |
|---|
| 1706 | { |
|---|
| 1707 | for( Int k = 0; k <= 2; k++ ) /* column */ |
|---|
| 1708 | { |
|---|
| 1709 | sei_read_flag( pDecodedMessageOutputStream, code, "sign_r" ); sei.m_signR [i][j][k] = (code == 1); |
|---|
| 1710 | sei_read_code( pDecodedMessageOutputStream, 6, code, "exponent_r" ); sei.m_exponentR[i][j][k] = code ; |
|---|
| 1711 | sei_read_code( pDecodedMessageOutputStream, sei.getMantissaRLen( i, j, k ), code, "mantissa_r" ); sei.m_mantissaR[i][j][k] = code ; |
|---|
| 1712 | } |
|---|
| 1713 | sei_read_flag( pDecodedMessageOutputStream, code, "sign_t" ); sei.m_signT [i][j] = (code == 1); |
|---|
| 1714 | sei_read_code( pDecodedMessageOutputStream, 6, code, "exponent_t" ); sei.m_exponentT[i][j] = code ; |
|---|
| 1715 | sei_read_code( pDecodedMessageOutputStream, sei.getMantissaTLen( i, j ), code, "mantissa_t" ); sei.m_mantissaT[i][j] = code ; |
|---|
| 1716 | } |
|---|
| 1717 | } |
|---|
| 1718 | } |
|---|
| 1719 | }; |
|---|
| 1720 | |
|---|
| 1721 | |
|---|
| 1722 | |
|---|
| 1723 | Void SEIReader::xParseSEIMultiviewViewPosition(SEIMultiviewViewPosition& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1724 | { |
|---|
| 1725 | UInt code; |
|---|
| 1726 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1727 | |
|---|
| 1728 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_views_minus1" ); sei.m_numViewsMinus1 = code; |
|---|
| 1729 | sei.m_viewPosition.resize( sei.m_numViewsMinus1 + 1 ); |
|---|
| 1730 | for( Int i = 0; i <= sei.m_numViewsMinus1; i++ ) |
|---|
| 1731 | { |
|---|
| 1732 | sei_read_uvlc( pDecodedMessageOutputStream, code, "view_position" ); sei.m_viewPosition[i] = code; |
|---|
| 1733 | } |
|---|
| 1734 | }; |
|---|
| 1735 | |
|---|
| 1736 | #endif |
|---|
| 1737 | |
|---|
| 1738 | //! \} |
|---|