| 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-2014, 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 Char *pSymbolName) |
|---|
| 66 | { |
|---|
| 67 | READ_CODE(uiLength, ruiCode, pSymbolName); |
|---|
| 68 | if (pOS) (*pOS) << " " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n"; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | Void SEIReader::sei_read_uvlc(std::ostream *pOS, UInt& ruiCode, const Char *pSymbolName) |
|---|
| 72 | { |
|---|
| 73 | READ_UVLC(ruiCode, pSymbolName); |
|---|
| 74 | if (pOS) (*pOS) << " " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n"; |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | Void SEIReader::sei_read_svlc(std::ostream *pOS, Int& ruiCode, const Char *pSymbolName) |
|---|
| 78 | { |
|---|
| 79 | READ_SVLC(ruiCode, pSymbolName); |
|---|
| 80 | if (pOS) (*pOS) << " " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n"; |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | Void SEIReader::sei_read_flag(std::ostream *pOS, UInt& ruiCode, const Char *pSymbolName) |
|---|
| 84 | { |
|---|
| 85 | READ_FLAG(ruiCode, pSymbolName); |
|---|
| 86 | if (pOS) (*pOS) << " " << std::setw(55) << pSymbolName << ": " << (ruiCode?1:0) << "\n"; |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | static inline Void output_sei_message_header(SEI &sei, std::ostream *pDecodedMessageOutputStream, UInt payloadSize) |
|---|
| 90 | { |
|---|
| 91 | if (pDecodedMessageOutputStream) |
|---|
| 92 | { |
|---|
| 93 | std::string seiMessageHdr(SEI::getSEIMessageString(sei.payloadType())); seiMessageHdr+=" SEI message"; |
|---|
| 94 | (*pDecodedMessageOutputStream) << std::setfill('-') << std::setw(seiMessageHdr.size()) << "-" << std::setfill(' ') << "\n" << seiMessageHdr << "\n"; |
|---|
| 95 | } |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | #undef READ_CODE |
|---|
| 99 | #undef READ_SVLC |
|---|
| 100 | #undef READ_UVLC |
|---|
| 101 | #undef READ_FLAG |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | /** |
|---|
| 105 | * unmarshal a single SEI message from bitstream bs |
|---|
| 106 | */ |
|---|
| 107 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 108 | Void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 109 | #else |
|---|
| 110 | Void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 111 | #endif |
|---|
| 112 | { |
|---|
| 113 | setBitstream(bs); |
|---|
| 114 | |
|---|
| 115 | assert(!m_pcBitstream->getNumBitsUntilByteAligned()); |
|---|
| 116 | do |
|---|
| 117 | { |
|---|
| 118 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 119 | xReadSEImessage(seis, nalUnitType, vps, sps, pDecodedMessageOutputStream); |
|---|
| 120 | #else |
|---|
| 121 | xReadSEImessage(seis, nalUnitType, sps, pDecodedMessageOutputStream); |
|---|
| 122 | #endif |
|---|
| 123 | /* SEI messages are an integer number of bytes, something has failed |
|---|
| 124 | * in the parsing if bitstream not byte-aligned */ |
|---|
| 125 | assert(!m_pcBitstream->getNumBitsUntilByteAligned()); |
|---|
| 126 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
|---|
| 127 | |
|---|
| 128 | UInt rbspTrailingBits; |
|---|
| 129 | sei_read_code(NULL, 8, rbspTrailingBits, "rbsp_trailing_bits"); |
|---|
| 130 | assert(rbspTrailingBits == 0x80); |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | #if O0164_MULTI_LAYER_HRD |
|---|
| 134 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 135 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream, const SEIScalableNesting *nestingSei, const SEIBspNesting *bspNestingSei) |
|---|
| 136 | #else |
|---|
| 137 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps, std::ostream *pDecodedMessageOutputStream, const SEIScalableNesting *nestingSei) |
|---|
| 138 | #endif |
|---|
| 139 | #else |
|---|
| 140 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 141 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 142 | #else |
|---|
| 143 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 144 | #endif |
|---|
| 145 | #endif |
|---|
| 146 | { |
|---|
| 147 | #if ENC_DEC_TRACE |
|---|
| 148 | xTraceSEIHeader(); |
|---|
| 149 | #endif |
|---|
| 150 | Int payloadType = 0; |
|---|
| 151 | UInt val = 0; |
|---|
| 152 | |
|---|
| 153 | do |
|---|
| 154 | { |
|---|
| 155 | sei_read_code(NULL, 8, val, "payload_type"); |
|---|
| 156 | payloadType += val; |
|---|
| 157 | } while (val==0xFF); |
|---|
| 158 | |
|---|
| 159 | UInt payloadSize = 0; |
|---|
| 160 | do |
|---|
| 161 | { |
|---|
| 162 | sei_read_code(NULL, 8, val, "payload_size"); |
|---|
| 163 | payloadSize += val; |
|---|
| 164 | } while (val==0xFF); |
|---|
| 165 | |
|---|
| 166 | #if ENC_DEC_TRACE |
|---|
| 167 | xTraceSEIMessageType((SEI::PayloadType)payloadType); |
|---|
| 168 | #endif |
|---|
| 169 | |
|---|
| 170 | /* extract the payload for this single SEI message. |
|---|
| 171 | * This allows greater safety in erroneous parsing of an SEI message |
|---|
| 172 | * from affecting subsequent messages. |
|---|
| 173 | * After parsing the payload, bs needs to be restored as the primary |
|---|
| 174 | * bitstream. |
|---|
| 175 | */ |
|---|
| 176 | TComInputBitstream *bs = getBitstream(); |
|---|
| 177 | setBitstream(bs->extractSubstream(payloadSize * 8)); |
|---|
| 178 | |
|---|
| 179 | SEI *sei = NULL; |
|---|
| 180 | |
|---|
| 181 | if(nalUnitType == NAL_UNIT_PREFIX_SEI) |
|---|
| 182 | { |
|---|
| 183 | switch (payloadType) |
|---|
| 184 | { |
|---|
| 185 | case SEI::USER_DATA_UNREGISTERED: |
|---|
| 186 | sei = new SEIuserDataUnregistered; |
|---|
| 187 | xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 188 | break; |
|---|
| 189 | case SEI::ACTIVE_PARAMETER_SETS: |
|---|
| 190 | sei = new SEIActiveParameterSets; |
|---|
| 191 | xParseSEIActiveParameterSets((SEIActiveParameterSets&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 192 | break; |
|---|
| 193 | case SEI::DECODING_UNIT_INFO: |
|---|
| 194 | if (!sps) |
|---|
| 195 | { |
|---|
| 196 | printf ("Warning: Found Decoding unit SEI message, but no active SPS is available. Ignoring."); |
|---|
| 197 | } |
|---|
| 198 | else |
|---|
| 199 | { |
|---|
| 200 | sei = new SEIDecodingUnitInfo; |
|---|
| 201 | #if VPS_VUI_BSP_HRD_PARAMS |
|---|
| 202 | xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps, nestingSei, bspNestingSei, vps, pDecodedMessageOutputStream); |
|---|
| 203 | #else |
|---|
| 204 | xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps, pDecodedMessageOutputStream); |
|---|
| 205 | #endif |
|---|
| 206 | } |
|---|
| 207 | break; |
|---|
| 208 | case SEI::BUFFERING_PERIOD: |
|---|
| 209 | if (!sps) |
|---|
| 210 | { |
|---|
| 211 | printf ("Warning: Found Buffering period SEI message, but no active SPS is available. Ignoring."); |
|---|
| 212 | } |
|---|
| 213 | else |
|---|
| 214 | { |
|---|
| 215 | sei = new SEIBufferingPeriod; |
|---|
| 216 | #if VPS_VUI_BSP_HRD_PARAMS |
|---|
| 217 | xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps, nestingSei, bspNestingSei, vps, pDecodedMessageOutputStream); |
|---|
| 218 | #else |
|---|
| 219 | xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps, pDecodedMessageOutputStream); |
|---|
| 220 | #endif |
|---|
| 221 | } |
|---|
| 222 | break; |
|---|
| 223 | case SEI::PICTURE_TIMING: |
|---|
| 224 | if (!sps) |
|---|
| 225 | { |
|---|
| 226 | printf ("Warning: Found Picture timing SEI message, but no active SPS is available. Ignoring."); |
|---|
| 227 | } |
|---|
| 228 | else |
|---|
| 229 | { |
|---|
| 230 | sei = new SEIPictureTiming; |
|---|
| 231 | #if VPS_VUI_BSP_HRD_PARAMS |
|---|
| 232 | xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps, nestingSei, bspNestingSei, vps, pDecodedMessageOutputStream); |
|---|
| 233 | #else |
|---|
| 234 | xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps, pDecodedMessageOutputStream); |
|---|
| 235 | #endif |
|---|
| 236 | } |
|---|
| 237 | break; |
|---|
| 238 | case SEI::RECOVERY_POINT: |
|---|
| 239 | sei = new SEIRecoveryPoint; |
|---|
| 240 | xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 241 | break; |
|---|
| 242 | case SEI::FRAME_PACKING: |
|---|
| 243 | sei = new SEIFramePacking; |
|---|
| 244 | xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 245 | break; |
|---|
| 246 | case SEI::SEGM_RECT_FRAME_PACKING: |
|---|
| 247 | sei = new SEISegmentedRectFramePacking; |
|---|
| 248 | xParseSEISegmentedRectFramePacking((SEISegmentedRectFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 249 | break; |
|---|
| 250 | case SEI::DISPLAY_ORIENTATION: |
|---|
| 251 | sei = new SEIDisplayOrientation; |
|---|
| 252 | xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 253 | break; |
|---|
| 254 | case SEI::TEMPORAL_LEVEL0_INDEX: |
|---|
| 255 | sei = new SEITemporalLevel0Index; |
|---|
| 256 | xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 257 | break; |
|---|
| 258 | case SEI::REGION_REFRESH_INFO: |
|---|
| 259 | sei = new SEIGradualDecodingRefreshInfo; |
|---|
| 260 | xParseSEIRegionRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 261 | break; |
|---|
| 262 | case SEI::NO_DISPLAY: |
|---|
| 263 | sei = new SEINoDisplay; |
|---|
| 264 | xParseSEINoDisplay((SEINoDisplay&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 265 | break; |
|---|
| 266 | case SEI::TONE_MAPPING_INFO: |
|---|
| 267 | sei = new SEIToneMappingInfo; |
|---|
| 268 | xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 269 | break; |
|---|
| 270 | case SEI::SOP_DESCRIPTION: |
|---|
| 271 | sei = new SEISOPDescription; |
|---|
| 272 | xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 273 | break; |
|---|
| 274 | case SEI::SCALABLE_NESTING: |
|---|
| 275 | sei = new SEIScalableNesting; |
|---|
| 276 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 277 | xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, vps, sps, pDecodedMessageOutputStream); |
|---|
| 278 | #else |
|---|
| 279 | xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps, pDecodedMessageOutputStream); |
|---|
| 280 | #endif |
|---|
| 281 | break; |
|---|
| 282 | case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS: |
|---|
| 283 | sei = new SEITempMotionConstrainedTileSets; |
|---|
| 284 | xParseSEITempMotionConstraintsTileSets((SEITempMotionConstrainedTileSets&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 285 | break; |
|---|
| 286 | case SEI::TIME_CODE: |
|---|
| 287 | sei = new SEITimeCode; |
|---|
| 288 | xParseSEITimeCode((SEITimeCode&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 289 | break; |
|---|
| 290 | case SEI::CHROMA_SAMPLING_FILTER_HINT: |
|---|
| 291 | sei = new SEIChromaSamplingFilterHint; |
|---|
| 292 | xParseSEIChromaSamplingFilterHint((SEIChromaSamplingFilterHint&) *sei, payloadSize/*, sps*/, pDecodedMessageOutputStream); |
|---|
| 293 | //} |
|---|
| 294 | break; |
|---|
| 295 | case SEI::KNEE_FUNCTION_INFO: |
|---|
| 296 | sei = new SEIKneeFunctionInfo; |
|---|
| 297 | xParseSEIKneeFunctionInfo((SEIKneeFunctionInfo&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 298 | break; |
|---|
| 299 | case SEI::MASTERING_DISPLAY_COLOUR_VOLUME: |
|---|
| 300 | sei = new SEIMasteringDisplayColourVolume; |
|---|
| 301 | xParseSEIMasteringDisplayColourVolume((SEIMasteringDisplayColourVolume&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 302 | break; |
|---|
| 303 | #if Q0074_COLOUR_REMAPPING_SEI |
|---|
| 304 | case SEI::COLOUR_REMAPPING_INFO: |
|---|
| 305 | sei = new SEIColourRemappingInfo; |
|---|
| 306 | xParseSEIColourRemappingInfo((SEIColourRemappingInfo&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 307 | break; |
|---|
| 308 | #endif |
|---|
| 309 | #if SVC_EXTENSION |
|---|
| 310 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 311 | case SEI::LAYERS_NOT_PRESENT: |
|---|
| 312 | if (!vps) |
|---|
| 313 | { |
|---|
| 314 | printf ("Warning: Found Layers not present SEI message, but no active VPS is available. Ignoring."); |
|---|
| 315 | } |
|---|
| 316 | else |
|---|
| 317 | { |
|---|
| 318 | sei = new SEILayersNotPresent; |
|---|
| 319 | xParseSEILayersNotPresent((SEILayersNotPresent&) *sei, payloadSize, vps, pDecodedMessageOutputStream); |
|---|
| 320 | } |
|---|
| 321 | break; |
|---|
| 322 | #endif |
|---|
| 323 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
|---|
| 324 | case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: |
|---|
| 325 | sei = new SEIInterLayerConstrainedTileSets; |
|---|
| 326 | xParseSEIInterLayerConstrainedTileSets((SEIInterLayerConstrainedTileSets&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 327 | break; |
|---|
| 328 | #endif |
|---|
| 329 | #if SUB_BITSTREAM_PROPERTY_SEI |
|---|
| 330 | case SEI::SUB_BITSTREAM_PROPERTY: |
|---|
| 331 | sei = new SEISubBitstreamProperty; |
|---|
| 332 | #if OLS_IDX_CHK |
|---|
| 333 | xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei, vps, pDecodedMessageOutputStream); |
|---|
| 334 | #else |
|---|
| 335 | xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei, pDecodedMessageOutputStream); |
|---|
| 336 | #endif |
|---|
| 337 | break; |
|---|
| 338 | #endif |
|---|
| 339 | #if O0164_MULTI_LAYER_HRD |
|---|
| 340 | case SEI::BSP_NESTING: |
|---|
| 341 | sei = new SEIBspNesting; |
|---|
| 342 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 343 | xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, vps, sps, *nestingSei, pDecodedMessageOutputStream); |
|---|
| 344 | #else |
|---|
| 345 | xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, sps, *nestingSei, pDecodedMessageOutputStream); |
|---|
| 346 | #endif |
|---|
| 347 | break; |
|---|
| 348 | case SEI::BSP_INITIAL_ARRIVAL_TIME: |
|---|
| 349 | sei = new SEIBspInitialArrivalTime; |
|---|
| 350 | xParseSEIBspInitialArrivalTime((SEIBspInitialArrivalTime&) *sei, vps, sps, *nestingSei, *bspNestingSei, pDecodedMessageOutputStream); |
|---|
| 351 | break; |
|---|
| 352 | #if !REMOVE_BSP_HRD_SEI |
|---|
| 353 | case SEI::BSP_HRD: |
|---|
| 354 | sei = new SEIBspHrd; |
|---|
| 355 | xParseSEIBspHrd((SEIBspHrd&) *sei, sps, *nestingSei, pDecodedMessageOutputStream); |
|---|
| 356 | break; |
|---|
| 357 | #endif |
|---|
| 358 | #endif |
|---|
| 359 | #if Q0078_ADD_LAYER_SETS |
|---|
| 360 | case SEI::OUTPUT_LAYER_SET_NESTING: |
|---|
| 361 | sei = new SEIOutputLayerSetNesting; |
|---|
| 362 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 363 | xParseSEIOutputLayerSetNesting((SEIOutputLayerSetNesting&)*sei, nalUnitType, vps, sps, pDecodedMessageOutputStream); |
|---|
| 364 | #else |
|---|
| 365 | xParseSEIOutputLayerSetNesting((SEIOutputLayerSetNesting&)*sei, nalUnitType, sps, pDecodedMessageOutputStream); |
|---|
| 366 | #endif |
|---|
| 367 | break; |
|---|
| 368 | case SEI::VPS_REWRITING: |
|---|
| 369 | sei = new SEIVPSRewriting; |
|---|
| 370 | xParseSEIVPSRewriting((SEIVPSRewriting&)*sei, pDecodedMessageOutputStream); |
|---|
| 371 | break; |
|---|
| 372 | #endif |
|---|
| 373 | #if Q0189_TMVP_CONSTRAINTS |
|---|
| 374 | case SEI::TMVP_CONSTRAINTS: |
|---|
| 375 | sei = new SEITMVPConstrains; |
|---|
| 376 | xParseSEITMVPConstraints((SEITMVPConstrains&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 377 | break; |
|---|
| 378 | #endif |
|---|
| 379 | #if Q0247_FRAME_FIELD_INFO |
|---|
| 380 | case SEI::FRAME_FIELD_INFO: |
|---|
| 381 | sei = new SEIFrameFieldInfo; |
|---|
| 382 | xParseSEIFrameFieldInfo ((SEIFrameFieldInfo&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 383 | break; |
|---|
| 384 | #endif |
|---|
| 385 | #if P0123_ALPHA_CHANNEL_SEI |
|---|
| 386 | case SEI::ALPHA_CHANNEL_INFO: |
|---|
| 387 | sei = new SEIAlphaChannelInfo; |
|---|
| 388 | xParseSEIAlphaChannelInfo((SEIAlphaChannelInfo &) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 389 | break; |
|---|
| 390 | #endif |
|---|
| 391 | #if Q0096_OVERLAY_SEI |
|---|
| 392 | case SEI::OVERLAY_INFO: |
|---|
| 393 | sei = new SEIOverlayInfo; |
|---|
| 394 | xParseSEIOverlayInfo((SEIOverlayInfo&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 395 | break; |
|---|
| 396 | #endif |
|---|
| 397 | #endif //SVC_EXTENSION |
|---|
| 398 | default: |
|---|
| 399 | for (UInt i = 0; i < payloadSize; i++) |
|---|
| 400 | { |
|---|
| 401 | UInt seiByte; |
|---|
| 402 | sei_read_code (NULL, 8, seiByte, "unknown prefix SEI payload byte"); |
|---|
| 403 | } |
|---|
| 404 | printf ("Unknown prefix SEI message (payloadType = %d) was found!\n", payloadType); |
|---|
| 405 | if (pDecodedMessageOutputStream) |
|---|
| 406 | { |
|---|
| 407 | (*pDecodedMessageOutputStream) << "Unknown prefix SEI message (payloadType = " << payloadType << ") was found!\n"; |
|---|
| 408 | } |
|---|
| 409 | break; |
|---|
| 410 | } |
|---|
| 411 | } |
|---|
| 412 | else |
|---|
| 413 | { |
|---|
| 414 | switch (payloadType) |
|---|
| 415 | { |
|---|
| 416 | case SEI::USER_DATA_UNREGISTERED: |
|---|
| 417 | sei = new SEIuserDataUnregistered; |
|---|
| 418 | xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 419 | break; |
|---|
| 420 | case SEI::DECODED_PICTURE_HASH: |
|---|
| 421 | sei = new SEIDecodedPictureHash; |
|---|
| 422 | xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize, pDecodedMessageOutputStream); |
|---|
| 423 | break; |
|---|
| 424 | default: |
|---|
| 425 | for (UInt i = 0; i < payloadSize; i++) |
|---|
| 426 | { |
|---|
| 427 | UInt seiByte; |
|---|
| 428 | sei_read_code( NULL, 8, seiByte, "unknown suffix SEI payload byte"); |
|---|
| 429 | } |
|---|
| 430 | printf ("Unknown suffix SEI message (payloadType = %d) was found!\n", payloadType); |
|---|
| 431 | if (pDecodedMessageOutputStream) |
|---|
| 432 | { |
|---|
| 433 | (*pDecodedMessageOutputStream) << "Unknown suffix SEI message (payloadType = " << payloadType << ") was found!\n"; |
|---|
| 434 | } |
|---|
| 435 | break; |
|---|
| 436 | } |
|---|
| 437 | } |
|---|
| 438 | |
|---|
| 439 | if (sei != NULL) |
|---|
| 440 | { |
|---|
| 441 | seis.push_back(sei); |
|---|
| 442 | } |
|---|
| 443 | |
|---|
| 444 | /* By definition the underlying bitstream terminates in a byte-aligned manner. |
|---|
| 445 | * 1. Extract all bar the last MIN(bitsremaining,nine) bits as reserved_payload_extension_data |
|---|
| 446 | * 2. Examine the final 8 bits to determine the payload_bit_equal_to_one marker |
|---|
| 447 | * 3. Extract the remainingreserved_payload_extension_data bits. |
|---|
| 448 | * |
|---|
| 449 | * If there are fewer than 9 bits available, extract them. |
|---|
| 450 | */ |
|---|
| 451 | Int payloadBitsRemaining = getBitstream()->getNumBitsLeft(); |
|---|
| 452 | if (payloadBitsRemaining) /* more_data_in_payload() */ |
|---|
| 453 | { |
|---|
| 454 | for (; payloadBitsRemaining > 9; payloadBitsRemaining--) |
|---|
| 455 | { |
|---|
| 456 | UInt reservedPayloadExtensionData; |
|---|
| 457 | sei_read_code ( pDecodedMessageOutputStream, 1, reservedPayloadExtensionData, "reserved_payload_extension_data"); |
|---|
| 458 | } |
|---|
| 459 | |
|---|
| 460 | /* 2 */ |
|---|
| 461 | Int finalBits = getBitstream()->peekBits(payloadBitsRemaining); |
|---|
| 462 | Int finalPayloadBits = 0; |
|---|
| 463 | for (Int mask = 0xff; finalBits & (mask >> finalPayloadBits); finalPayloadBits++) |
|---|
| 464 | { |
|---|
| 465 | continue; |
|---|
| 466 | } |
|---|
| 467 | |
|---|
| 468 | /* 3 */ |
|---|
| 469 | for (; payloadBitsRemaining > 9 - finalPayloadBits; payloadBitsRemaining--) |
|---|
| 470 | { |
|---|
| 471 | UInt reservedPayloadExtensionData; |
|---|
| 472 | sei_read_flag ( 0, reservedPayloadExtensionData, "reserved_payload_extension_data"); |
|---|
| 473 | } |
|---|
| 474 | |
|---|
| 475 | UInt dummy; |
|---|
| 476 | sei_read_flag( 0, dummy, "payload_bit_equal_to_one"); payloadBitsRemaining--; |
|---|
| 477 | while (payloadBitsRemaining) |
|---|
| 478 | { |
|---|
| 479 | sei_read_flag( 0, dummy, "payload_bit_equal_to_zero"); payloadBitsRemaining--; |
|---|
| 480 | } |
|---|
| 481 | } |
|---|
| 482 | |
|---|
| 483 | /* restore primary bitstream for sei_message */ |
|---|
| 484 | getBitstream()->deleteFifo(); |
|---|
| 485 | delete getBitstream(); |
|---|
| 486 | setBitstream(bs); |
|---|
| 487 | } |
|---|
| 488 | |
|---|
| 489 | /** |
|---|
| 490 | * parse bitstream bs and unpack a user_data_unregistered SEI message |
|---|
| 491 | * of payloasSize bytes into sei. |
|---|
| 492 | */ |
|---|
| 493 | |
|---|
| 494 | Void SEIReader::xParseSEIuserDataUnregistered(SEIuserDataUnregistered &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 495 | { |
|---|
| 496 | assert(payloadSize >= ISO_IEC_11578_LEN); |
|---|
| 497 | UInt val; |
|---|
| 498 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 499 | |
|---|
| 500 | for (UInt i = 0; i < ISO_IEC_11578_LEN; i++) |
|---|
| 501 | { |
|---|
| 502 | sei_read_code( pDecodedMessageOutputStream, 8, val, "uuid_iso_iec_11578"); |
|---|
| 503 | sei.uuid_iso_iec_11578[i] = val; |
|---|
| 504 | } |
|---|
| 505 | |
|---|
| 506 | sei.userDataLength = payloadSize - ISO_IEC_11578_LEN; |
|---|
| 507 | if (!sei.userDataLength) |
|---|
| 508 | { |
|---|
| 509 | sei.userData = 0; |
|---|
| 510 | return; |
|---|
| 511 | } |
|---|
| 512 | |
|---|
| 513 | sei.userData = new UChar[sei.userDataLength]; |
|---|
| 514 | for (UInt i = 0; i < sei.userDataLength; i++) |
|---|
| 515 | { |
|---|
| 516 | sei_read_code( pDecodedMessageOutputStream, 8, val, "user_data" ); |
|---|
| 517 | sei.userData[i] = val; |
|---|
| 518 | } |
|---|
| 519 | } |
|---|
| 520 | |
|---|
| 521 | /** |
|---|
| 522 | * parse bitstream bs and unpack a decoded picture hash SEI message |
|---|
| 523 | * of payloadSize bytes into sei. |
|---|
| 524 | */ |
|---|
| 525 | Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 526 | { |
|---|
| 527 | UInt bytesRead = 0; |
|---|
| 528 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 529 | |
|---|
| 530 | UInt val; |
|---|
| 531 | sei_read_code( pDecodedMessageOutputStream, 8, val, "hash_type"); |
|---|
| 532 | sei.method = static_cast<SEIDecodedPictureHash::Method>(val); bytesRead++; |
|---|
| 533 | |
|---|
| 534 | const Char *traceString="\0"; |
|---|
| 535 | switch (sei.method) |
|---|
| 536 | { |
|---|
| 537 | case SEIDecodedPictureHash::MD5: traceString="picture_md5"; break; |
|---|
| 538 | case SEIDecodedPictureHash::CRC: traceString="picture_crc"; break; |
|---|
| 539 | case SEIDecodedPictureHash::CHECKSUM: traceString="picture_checksum"; break; |
|---|
| 540 | default: assert(false); break; |
|---|
| 541 | } |
|---|
| 542 | |
|---|
| 543 | if (pDecodedMessageOutputStream) (*pDecodedMessageOutputStream) << " " << std::setw(55) << traceString << ": " << std::hex << std::setfill('0'); |
|---|
| 544 | |
|---|
| 545 | sei.m_digest.hash.clear(); |
|---|
| 546 | for(;bytesRead < payloadSize; bytesRead++) |
|---|
| 547 | { |
|---|
| 548 | sei_read_code( NULL, 8, val, traceString); |
|---|
| 549 | sei.m_digest.hash.push_back((UChar)val); |
|---|
| 550 | if (pDecodedMessageOutputStream) (*pDecodedMessageOutputStream) << std::setw(2) << val; |
|---|
| 551 | } |
|---|
| 552 | |
|---|
| 553 | if (pDecodedMessageOutputStream) (*pDecodedMessageOutputStream) << std::dec << std::setfill(' ') << "\n"; |
|---|
| 554 | } |
|---|
| 555 | |
|---|
| 556 | Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 557 | { |
|---|
| 558 | UInt val; |
|---|
| 559 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 560 | |
|---|
| 561 | sei_read_code( pDecodedMessageOutputStream, 4, val, "active_video_parameter_set_id"); sei.activeVPSId = val; |
|---|
| 562 | sei_read_flag( pDecodedMessageOutputStream, val, "self_contained_cvs_flag"); sei.m_selfContainedCvsFlag = (val != 0); |
|---|
| 563 | sei_read_flag( pDecodedMessageOutputStream, val, "no_parameter_set_update_flag"); sei.m_noParameterSetUpdateFlag = (val != 0); |
|---|
| 564 | sei_read_uvlc( pDecodedMessageOutputStream, val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val; |
|---|
| 565 | |
|---|
| 566 | sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1); |
|---|
| 567 | #if R0247_SEI_ACTIVE |
|---|
| 568 | sei.layerSpsIdx.resize(sei.numSpsIdsMinus1 + 1); |
|---|
| 569 | #endif |
|---|
| 570 | for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++) |
|---|
| 571 | { |
|---|
| 572 | sei_read_uvlc( pDecodedMessageOutputStream, val, "active_seq_parameter_set_id[i]"); sei.activeSeqParameterSetId[i] = val; |
|---|
| 573 | } |
|---|
| 574 | #if R0247_SEI_ACTIVE |
|---|
| 575 | for (Int i=1; i < (sei.numSpsIdsMinus1 + 1); i++) |
|---|
| 576 | { |
|---|
| 577 | sei_read_uvlc( pDecodedMessageOutputStream, val, "layer_sps_idx"); sei.layerSpsIdx[i] = val; |
|---|
| 578 | } |
|---|
| 579 | #endif |
|---|
| 580 | } |
|---|
| 581 | |
|---|
| 582 | #if VPS_VUI_BSP_HRD_PARAMS |
|---|
| 583 | Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps,std::ostream *pDecodedMessageOutputStream) |
|---|
| 584 | #else |
|---|
| 585 | Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt payloadSize, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 586 | #endif |
|---|
| 587 | { |
|---|
| 588 | UInt val; |
|---|
| 589 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 590 | sei_read_uvlc( pDecodedMessageOutputStream, val, "decoding_unit_idx"); |
|---|
| 591 | sei.m_decodingUnitIdx = val; |
|---|
| 592 | |
|---|
| 593 | #if VPS_VUI_BSP_HRD_PARAMS |
|---|
| 594 | TComHRD *hrd; |
|---|
| 595 | if( bspNestingSei ) // If DU info SEI contained inside a BSP nesting SEI message |
|---|
| 596 | { |
|---|
| 597 | assert( nestingSei ); |
|---|
| 598 | Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx; |
|---|
| 599 | Int seiOlsIdx = bspNestingSei->m_seiOlsIdx; |
|---|
| 600 | Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1; |
|---|
| 601 | Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; |
|---|
| 602 | std::vector<Int> hrdIdx(maxValues, 0); |
|---|
| 603 | std::vector<TComHRD *> hrdVec; |
|---|
| 604 | std::vector<Int> syntaxElemLen(maxValues, 0); |
|---|
| 605 | for(Int i = 0; i < maxValues; i++) |
|---|
| 606 | { |
|---|
| 607 | hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); |
|---|
| 608 | hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); |
|---|
| 609 | |
|---|
| 610 | syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; |
|---|
| 611 | if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) |
|---|
| 612 | { |
|---|
| 613 | assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 |
|---|
| 614 | } |
|---|
| 615 | if( i > 0 ) |
|---|
| 616 | { |
|---|
| 617 | assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); |
|---|
| 618 | assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag() == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() ); |
|---|
| 619 | assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); |
|---|
| 620 | // To be done: Check CpbDpbDelaysPresentFlag |
|---|
| 621 | } |
|---|
| 622 | } |
|---|
| 623 | hrd = hrdVec[0]; |
|---|
| 624 | } |
|---|
| 625 | else |
|---|
| 626 | { |
|---|
| 627 | TComVUI *vui = sps->getVuiParameters(); |
|---|
| 628 | hrd = vui->getHrdParameters(); |
|---|
| 629 | } |
|---|
| 630 | |
|---|
| 631 | if(hrd->getSubPicCpbParamsInPicTimingSEIFlag()) |
|---|
| 632 | { |
|---|
| 633 | sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay_increment"); |
|---|
| 634 | sei.m_duSptCpbRemovalDelay = val; |
|---|
| 635 | } |
|---|
| 636 | else |
|---|
| 637 | { |
|---|
| 638 | sei.m_duSptCpbRemovalDelay = 0; |
|---|
| 639 | } |
|---|
| 640 | sei_read_flag( pDecodedMessageOutputStream, val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = (val != 0); |
|---|
| 641 | if(sei.m_dpbOutputDuDelayPresentFlag) |
|---|
| 642 | { |
|---|
| 643 | sei_read_code( pDecodedMessageOutputStream, hrd->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay"); |
|---|
| 644 | sei.m_picSptDpbOutputDuDelay = val; |
|---|
| 645 | } |
|---|
| 646 | #else |
|---|
| 647 | TComVUI *vui = sps->getVuiParameters(); |
|---|
| 648 | |
|---|
| 649 | if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag()) |
|---|
| 650 | { |
|---|
| 651 | sei_read_code( pDecodedMessageOutputStream, ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay_increment"); |
|---|
| 652 | sei.m_duSptCpbRemovalDelay = val; |
|---|
| 653 | } |
|---|
| 654 | else |
|---|
| 655 | { |
|---|
| 656 | sei.m_duSptCpbRemovalDelay = 0; |
|---|
| 657 | } |
|---|
| 658 | sei_read_flag( pDecodedMessageOutputStream, val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = (val != 0); |
|---|
| 659 | if(sei.m_dpbOutputDuDelayPresentFlag) |
|---|
| 660 | { |
|---|
| 661 | sei_read_code( pDecodedMessageOutputStream, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay"); |
|---|
| 662 | sei.m_picSptDpbOutputDuDelay = val; |
|---|
| 663 | } |
|---|
| 664 | #endif |
|---|
| 665 | } |
|---|
| 666 | |
|---|
| 667 | #if VPS_VUI_BSP_HRD_PARAMS |
|---|
| 668 | Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 669 | #else |
|---|
| 670 | Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt payloadSize, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 671 | #endif |
|---|
| 672 | { |
|---|
| 673 | Int i, nalOrVcl; |
|---|
| 674 | UInt code; |
|---|
| 675 | |
|---|
| 676 | #if VPS_VUI_BSP_HRD_PARAMS |
|---|
| 677 | TComHRD *pHRD; |
|---|
| 678 | if( bspNestingSei ) // If BP SEI contained inside a BSP nesting SEI message |
|---|
| 679 | { |
|---|
| 680 | assert( nestingSei ); |
|---|
| 681 | Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx; |
|---|
| 682 | Int seiOlsIdx = bspNestingSei->m_seiOlsIdx; |
|---|
| 683 | Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1; |
|---|
| 684 | Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; |
|---|
| 685 | std::vector<Int> hrdIdx(maxValues, 0); |
|---|
| 686 | std::vector<TComHRD *> hrdVec; |
|---|
| 687 | std::vector<Int> syntaxElemLen(maxValues, 0); |
|---|
| 688 | for(i = 0; i < maxValues; i++) |
|---|
| 689 | { |
|---|
| 690 | hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); |
|---|
| 691 | hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); |
|---|
| 692 | |
|---|
| 693 | syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; |
|---|
| 694 | if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) |
|---|
| 695 | { |
|---|
| 696 | assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 |
|---|
| 697 | } |
|---|
| 698 | if( i > 0 ) |
|---|
| 699 | { |
|---|
| 700 | assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() ); |
|---|
| 701 | assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); |
|---|
| 702 | assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); |
|---|
| 703 | } |
|---|
| 704 | } |
|---|
| 705 | pHRD = hrdVec[i]; |
|---|
| 706 | } |
|---|
| 707 | else |
|---|
| 708 | { |
|---|
| 709 | TComVUI *vui = sps->getVuiParameters(); |
|---|
| 710 | pHRD = vui->getHrdParameters(); |
|---|
| 711 | } |
|---|
| 712 | // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently. |
|---|
| 713 | #else |
|---|
| 714 | TComVUI *pVUI = sps->getVuiParameters(); |
|---|
| 715 | TComHRD *pHRD = pVUI->getHrdParameters(); |
|---|
| 716 | #endif |
|---|
| 717 | |
|---|
| 718 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 719 | |
|---|
| 720 | sei_read_uvlc( pDecodedMessageOutputStream, code, "bp_seq_parameter_set_id" ); sei.m_bpSeqParameterSetId = code; |
|---|
| 721 | if( !pHRD->getSubPicCpbParamsPresentFlag() ) |
|---|
| 722 | { |
|---|
| 723 | sei_read_flag( pDecodedMessageOutputStream, code, "irap_cpb_params_present_flag" ); sei.m_rapCpbParamsPresentFlag = code; |
|---|
| 724 | } |
|---|
| 725 | if( sei.m_rapCpbParamsPresentFlag ) |
|---|
| 726 | { |
|---|
| 727 | sei_read_code( pDecodedMessageOutputStream, pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" ); sei.m_cpbDelayOffset = code; |
|---|
| 728 | sei_read_code( pDecodedMessageOutputStream, pHRD->getDpbOutputDelayLengthMinus1() + 1, code, "dpb_delay_offset" ); sei.m_dpbDelayOffset = code; |
|---|
| 729 | } |
|---|
| 730 | |
|---|
| 731 | //read splicing flag and cpb_removal_delay_delta |
|---|
| 732 | sei_read_flag( pDecodedMessageOutputStream, code, "concatenation_flag"); |
|---|
| 733 | sei.m_concatenationFlag = code; |
|---|
| 734 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" ); |
|---|
| 735 | sei.m_auCpbRemovalDelayDelta = code + 1; |
|---|
| 736 | |
|---|
| 737 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
|---|
| 738 | { |
|---|
| 739 | if( ( ( nalOrVcl == 0 ) && ( pHRD->getNalHrdParametersPresentFlag() ) ) || |
|---|
| 740 | ( ( nalOrVcl == 1 ) && ( pHRD->getVclHrdParametersPresentFlag() ) ) ) |
|---|
| 741 | { |
|---|
| 742 | for( i = 0; i < ( pHRD->getCpbCntMinus1( 0 ) + 1 ); i ++ ) |
|---|
| 743 | { |
|---|
| 744 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_cpb_removal_delay":"nal_initial_cpb_removal_delay" ); |
|---|
| 745 | sei.m_initialCpbRemovalDelay[i][nalOrVcl] = code; |
|---|
| 746 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_cpb_removal_offset":"vcl_initial_cpb_removal_offset" ); |
|---|
| 747 | sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl] = code; |
|---|
| 748 | if( pHRD->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag ) |
|---|
| 749 | { |
|---|
| 750 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_alt_cpb_removal_delay":"vcl_initial_alt_cpb_removal_delay" ); |
|---|
| 751 | sei.m_initialAltCpbRemovalDelay[i][nalOrVcl] = code; |
|---|
| 752 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_alt_cpb_removal_offset":"vcl_initial_alt_cpb_removal_offset" ); |
|---|
| 753 | sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl] = code; |
|---|
| 754 | } |
|---|
| 755 | } |
|---|
| 756 | } |
|---|
| 757 | } |
|---|
| 758 | |
|---|
| 759 | #if P0138_USE_ALT_CPB_PARAMS_FLAG |
|---|
| 760 | sei.m_useAltCpbParamsFlag = false; |
|---|
| 761 | sei.m_useAltCpbParamsFlagPresent = false; |
|---|
| 762 | if (xPayloadExtensionPresent()) |
|---|
| 763 | { |
|---|
| 764 | sei_read_flag( pDecodedMessageOutputStream, code, "use_alt_cpb_params_flag"); |
|---|
| 765 | sei.m_useAltCpbParamsFlag = code; |
|---|
| 766 | sei.m_useAltCpbParamsFlagPresent = true; |
|---|
| 767 | } |
|---|
| 768 | #endif |
|---|
| 769 | } |
|---|
| 770 | |
|---|
| 771 | #if VPS_VUI_BSP_HRD_PARAMS |
|---|
| 772 | Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 773 | #else |
|---|
| 774 | Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt payloadSize, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 775 | #endif |
|---|
| 776 | { |
|---|
| 777 | Int i; |
|---|
| 778 | UInt code; |
|---|
| 779 | |
|---|
| 780 | #if VPS_VUI_BSP_HRD_PARAMS |
|---|
| 781 | TComHRD *hrd; |
|---|
| 782 | TComVUI *vui = sps->getVuiParameters(); |
|---|
| 783 | if( bspNestingSei ) // If BP SEI contained inside a BSP nesting SEI message |
|---|
| 784 | { |
|---|
| 785 | assert( nestingSei ); |
|---|
| 786 | Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx; |
|---|
| 787 | Int seiOlsIdx = bspNestingSei->m_seiOlsIdx; |
|---|
| 788 | Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1; |
|---|
| 789 | Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; |
|---|
| 790 | std::vector<Int> hrdIdx(maxValues, 0); |
|---|
| 791 | std::vector<TComHRD *> hrdVec; |
|---|
| 792 | std::vector<Int> syntaxElemLen(maxValues, 0); |
|---|
| 793 | for(i = 0; i < maxValues; i++) |
|---|
| 794 | { |
|---|
| 795 | hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); |
|---|
| 796 | hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); |
|---|
| 797 | |
|---|
| 798 | syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; |
|---|
| 799 | if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) |
|---|
| 800 | { |
|---|
| 801 | assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 |
|---|
| 802 | } |
|---|
| 803 | if( i > 0 ) |
|---|
| 804 | { |
|---|
| 805 | assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); |
|---|
| 806 | assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag() == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() ); |
|---|
| 807 | assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() ); |
|---|
| 808 | assert( hrdVec[i]->getDpbOutputDelayLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayLengthMinus1() ); |
|---|
| 809 | assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); |
|---|
| 810 | assert( hrdVec[i]->getDuCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getDuCpbRemovalDelayLengthMinus1() ); |
|---|
| 811 | // To be done: Check CpbDpbDelaysPresentFlag |
|---|
| 812 | } |
|---|
| 813 | } |
|---|
| 814 | hrd = hrdVec[0]; |
|---|
| 815 | } |
|---|
| 816 | else |
|---|
| 817 | { |
|---|
| 818 | hrd = vui->getHrdParameters(); |
|---|
| 819 | } |
|---|
| 820 | // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently. |
|---|
| 821 | #else |
|---|
| 822 | TComVUI *vui = sps->getVuiParameters(); |
|---|
| 823 | TComHRD *hrd = vui->getHrdParameters(); |
|---|
| 824 | #endif |
|---|
| 825 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 826 | |
|---|
| 827 | if( vui->getFrameFieldInfoPresentFlag() ) |
|---|
| 828 | { |
|---|
| 829 | sei_read_code( pDecodedMessageOutputStream, 4, code, "pic_struct" ); sei.m_picStruct = code; |
|---|
| 830 | sei_read_code( pDecodedMessageOutputStream, 2, code, "source_scan_type" ); sei.m_sourceScanType = code; |
|---|
| 831 | sei_read_flag( pDecodedMessageOutputStream, code, "duplicate_flag" ); sei.m_duplicateFlag = (code == 1); |
|---|
| 832 | } |
|---|
| 833 | |
|---|
| 834 | if( hrd->getCpbDpbDelaysPresentFlag()) |
|---|
| 835 | { |
|---|
| 836 | sei_read_code( pDecodedMessageOutputStream, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" ); |
|---|
| 837 | sei.m_auCpbRemovalDelay = code + 1; |
|---|
| 838 | sei_read_code( pDecodedMessageOutputStream, ( hrd->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" ); |
|---|
| 839 | sei.m_picDpbOutputDelay = code; |
|---|
| 840 | |
|---|
| 841 | if(hrd->getSubPicCpbParamsPresentFlag()) |
|---|
| 842 | { |
|---|
| 843 | sei_read_code( pDecodedMessageOutputStream, hrd->getDpbOutputDelayDuLengthMinus1()+1, code, "pic_dpb_output_du_delay" ); |
|---|
| 844 | sei.m_picDpbOutputDuDelay = code; |
|---|
| 845 | } |
|---|
| 846 | |
|---|
| 847 | if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() ) |
|---|
| 848 | { |
|---|
| 849 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_decoding_units_minus1"); |
|---|
| 850 | sei.m_numDecodingUnitsMinus1 = code; |
|---|
| 851 | sei_read_flag( pDecodedMessageOutputStream, code, "du_common_cpb_removal_delay_flag" ); |
|---|
| 852 | sei.m_duCommonCpbRemovalDelayFlag = code; |
|---|
| 853 | if( sei.m_duCommonCpbRemovalDelayFlag ) |
|---|
| 854 | { |
|---|
| 855 | sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_increment_minus1" ); |
|---|
| 856 | sei.m_duCommonCpbRemovalDelayMinus1 = code; |
|---|
| 857 | } |
|---|
| 858 | if( sei.m_numNalusInDuMinus1 != NULL ) |
|---|
| 859 | { |
|---|
| 860 | delete sei.m_numNalusInDuMinus1; |
|---|
| 861 | } |
|---|
| 862 | sei.m_numNalusInDuMinus1 = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ]; |
|---|
| 863 | if( sei.m_duCpbRemovalDelayMinus1 != NULL ) |
|---|
| 864 | { |
|---|
| 865 | delete sei.m_duCpbRemovalDelayMinus1; |
|---|
| 866 | } |
|---|
| 867 | sei.m_duCpbRemovalDelayMinus1 = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ]; |
|---|
| 868 | |
|---|
| 869 | for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ ) |
|---|
| 870 | { |
|---|
| 871 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_nalus_in_du_minus1[i]"); |
|---|
| 872 | sei.m_numNalusInDuMinus1[ i ] = code; |
|---|
| 873 | if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) ) |
|---|
| 874 | { |
|---|
| 875 | sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1[i]" ); |
|---|
| 876 | sei.m_duCpbRemovalDelayMinus1[ i ] = code; |
|---|
| 877 | } |
|---|
| 878 | } |
|---|
| 879 | } |
|---|
| 880 | } |
|---|
| 881 | } |
|---|
| 882 | |
|---|
| 883 | Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& 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_svlc( pDecodedMessageOutputStream, iCode, "recovery_poc_cnt" ); sei.m_recoveryPocCnt = iCode; |
|---|
| 890 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "exact_matching_flag" ); sei.m_exactMatchingFlag = uiCode; |
|---|
| 891 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "broken_link_flag" ); sei.m_brokenLinkFlag = uiCode; |
|---|
| 892 | } |
|---|
| 893 | |
|---|
| 894 | Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 895 | { |
|---|
| 896 | UInt val; |
|---|
| 897 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 898 | |
|---|
| 899 | sei_read_uvlc( pDecodedMessageOutputStream, val, "frame_packing_arrangement_id" ); sei.m_arrangementId = val; |
|---|
| 900 | sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; |
|---|
| 901 | |
|---|
| 902 | if ( !sei.m_arrangementCancelFlag ) |
|---|
| 903 | { |
|---|
| 904 | sei_read_code( pDecodedMessageOutputStream, 7, val, "frame_packing_arrangement_type" ); sei.m_arrangementType = val; |
|---|
| 905 | assert((sei.m_arrangementType > 2) && (sei.m_arrangementType < 6) ); |
|---|
| 906 | |
|---|
| 907 | sei_read_flag( pDecodedMessageOutputStream, val, "quincunx_sampling_flag" ); sei.m_quincunxSamplingFlag = val; |
|---|
| 908 | |
|---|
| 909 | sei_read_code( pDecodedMessageOutputStream, 6, val, "content_interpretation_type" ); sei.m_contentInterpretationType = val; |
|---|
| 910 | sei_read_flag( pDecodedMessageOutputStream, val, "spatial_flipping_flag" ); sei.m_spatialFlippingFlag = val; |
|---|
| 911 | sei_read_flag( pDecodedMessageOutputStream, val, "frame0_flipped_flag" ); sei.m_frame0FlippedFlag = val; |
|---|
| 912 | sei_read_flag( pDecodedMessageOutputStream, val, "field_views_flag" ); sei.m_fieldViewsFlag = val; |
|---|
| 913 | sei_read_flag( pDecodedMessageOutputStream, val, "current_frame_is_frame0_flag" ); sei.m_currentFrameIsFrame0Flag = val; |
|---|
| 914 | sei_read_flag( pDecodedMessageOutputStream, val, "frame0_self_contained_flag" ); sei.m_frame0SelfContainedFlag = val; |
|---|
| 915 | sei_read_flag( pDecodedMessageOutputStream, val, "frame1_self_contained_flag" ); sei.m_frame1SelfContainedFlag = val; |
|---|
| 916 | |
|---|
| 917 | if ( sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5) |
|---|
| 918 | { |
|---|
| 919 | sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_x" ); sei.m_frame0GridPositionX = val; |
|---|
| 920 | sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_y" ); sei.m_frame0GridPositionY = val; |
|---|
| 921 | sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_x" ); sei.m_frame1GridPositionX = val; |
|---|
| 922 | sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_y" ); sei.m_frame1GridPositionY = val; |
|---|
| 923 | } |
|---|
| 924 | |
|---|
| 925 | sei_read_code( pDecodedMessageOutputStream, 8, val, "frame_packing_arrangement_reserved_byte" ); sei.m_arrangementReservedByte = val; |
|---|
| 926 | sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_persistence_flag" ); sei.m_arrangementPersistenceFlag = (val != 0); |
|---|
| 927 | } |
|---|
| 928 | sei_read_flag( pDecodedMessageOutputStream, val, "upsampled_aspect_ratio_flag" ); sei.m_upsampledAspectRatio = val; |
|---|
| 929 | } |
|---|
| 930 | |
|---|
| 931 | Void SEIReader::xParseSEISegmentedRectFramePacking(SEISegmentedRectFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 932 | { |
|---|
| 933 | UInt val; |
|---|
| 934 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 935 | sei_read_flag( pDecodedMessageOutputStream, val, "segmented_rect_frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; |
|---|
| 936 | if( !sei.m_arrangementCancelFlag ) |
|---|
| 937 | { |
|---|
| 938 | sei_read_code( pDecodedMessageOutputStream, 2, val, "segmented_rect_content_interpretation_type" ); sei.m_contentInterpretationType = val; |
|---|
| 939 | sei_read_flag( pDecodedMessageOutputStream, val, "segmented_rect_frame_packing_arrangement_persistence" ); sei.m_arrangementPersistenceFlag = val; |
|---|
| 940 | } |
|---|
| 941 | } |
|---|
| 942 | |
|---|
| 943 | Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 944 | { |
|---|
| 945 | UInt val; |
|---|
| 946 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 947 | sei_read_flag( pDecodedMessageOutputStream, val, "display_orientation_cancel_flag" ); sei.cancelFlag = val; |
|---|
| 948 | if( !sei.cancelFlag ) |
|---|
| 949 | { |
|---|
| 950 | sei_read_flag( pDecodedMessageOutputStream, val, "hor_flip" ); sei.horFlip = val; |
|---|
| 951 | sei_read_flag( pDecodedMessageOutputStream, val, "ver_flip" ); sei.verFlip = val; |
|---|
| 952 | sei_read_code( pDecodedMessageOutputStream, 16, val, "anticlockwise_rotation" ); sei.anticlockwiseRotation = val; |
|---|
| 953 | sei_read_flag( pDecodedMessageOutputStream, val, "display_orientation_persistence_flag" ); sei.persistenceFlag = val; |
|---|
| 954 | } |
|---|
| 955 | } |
|---|
| 956 | |
|---|
| 957 | Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 958 | { |
|---|
| 959 | UInt val; |
|---|
| 960 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 961 | sei_read_code( pDecodedMessageOutputStream, 8, val, "temporal_sub_layer_zero_idx" ); sei.tl0Idx = val; |
|---|
| 962 | sei_read_code( pDecodedMessageOutputStream, 8, val, "irap_pic_id" ); sei.rapIdx = val; |
|---|
| 963 | } |
|---|
| 964 | |
|---|
| 965 | Void SEIReader::xParseSEIRegionRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 966 | { |
|---|
| 967 | UInt val; |
|---|
| 968 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 969 | sei_read_flag( pDecodedMessageOutputStream, val, "refreshed_region_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0; |
|---|
| 970 | } |
|---|
| 971 | |
|---|
| 972 | Void SEIReader::xParseSEINoDisplay(SEINoDisplay& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 973 | { |
|---|
| 974 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 975 | sei.m_noDisplay = true; |
|---|
| 976 | } |
|---|
| 977 | |
|---|
| 978 | Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 979 | { |
|---|
| 980 | Int i; |
|---|
| 981 | UInt val; |
|---|
| 982 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 983 | sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_id" ); sei.m_toneMapId = val; |
|---|
| 984 | sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_cancel_flag" ); sei.m_toneMapCancelFlag = val; |
|---|
| 985 | |
|---|
| 986 | if ( !sei.m_toneMapCancelFlag ) |
|---|
| 987 | { |
|---|
| 988 | sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_persistence_flag" ); sei.m_toneMapPersistenceFlag = val; |
|---|
| 989 | sei_read_code( pDecodedMessageOutputStream, 8, val, "coded_data_bit_depth" ); sei.m_codedDataBitDepth = val; |
|---|
| 990 | sei_read_code( pDecodedMessageOutputStream, 8, val, "target_bit_depth" ); sei.m_targetBitDepth = val; |
|---|
| 991 | sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_model_id" ); sei.m_modelId = val; |
|---|
| 992 | switch(sei.m_modelId) |
|---|
| 993 | { |
|---|
| 994 | case 0: |
|---|
| 995 | { |
|---|
| 996 | sei_read_code( pDecodedMessageOutputStream, 32, val, "min_value" ); sei.m_minValue = val; |
|---|
| 997 | sei_read_code( pDecodedMessageOutputStream, 32, val, "max_value" ); sei.m_maxValue = val; |
|---|
| 998 | break; |
|---|
| 999 | } |
|---|
| 1000 | case 1: |
|---|
| 1001 | { |
|---|
| 1002 | sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_midpoint" ); sei.m_sigmoidMidpoint = val; |
|---|
| 1003 | sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_width" ); sei.m_sigmoidWidth = val; |
|---|
| 1004 | break; |
|---|
| 1005 | } |
|---|
| 1006 | case 2: |
|---|
| 1007 | { |
|---|
| 1008 | UInt num = 1u << sei.m_targetBitDepth; |
|---|
| 1009 | sei.m_startOfCodedInterval.resize(num+1); |
|---|
| 1010 | for(i = 0; i < num; i++) |
|---|
| 1011 | { |
|---|
| 1012 | sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval[i]" ); |
|---|
| 1013 | sei.m_startOfCodedInterval[i] = val; |
|---|
| 1014 | } |
|---|
| 1015 | sei.m_startOfCodedInterval[num] = 1u << sei.m_codedDataBitDepth; |
|---|
| 1016 | break; |
|---|
| 1017 | } |
|---|
| 1018 | case 3: |
|---|
| 1019 | { |
|---|
| 1020 | sei_read_code( pDecodedMessageOutputStream, 16, val, "num_pivots" ); sei.m_numPivots = val; |
|---|
| 1021 | sei.m_codedPivotValue.resize(sei.m_numPivots); |
|---|
| 1022 | sei.m_targetPivotValue.resize(sei.m_numPivots); |
|---|
| 1023 | for(i = 0; i < sei.m_numPivots; i++ ) |
|---|
| 1024 | { |
|---|
| 1025 | sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value[i]" ); |
|---|
| 1026 | sei.m_codedPivotValue[i] = val; |
|---|
| 1027 | sei_read_code( pDecodedMessageOutputStream, ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3), val, "target_pivot_value[i]" ); |
|---|
| 1028 | sei.m_targetPivotValue[i] = val; |
|---|
| 1029 | } |
|---|
| 1030 | break; |
|---|
| 1031 | } |
|---|
| 1032 | case 4: |
|---|
| 1033 | { |
|---|
| 1034 | sei_read_code( pDecodedMessageOutputStream, 8, val, "camera_iso_speed_idc" ); sei.m_cameraIsoSpeedIdc = val; |
|---|
| 1035 | if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO |
|---|
| 1036 | { |
|---|
| 1037 | sei_read_code( pDecodedMessageOutputStream, 32, val, "camera_iso_speed_value" ); sei.m_cameraIsoSpeedValue = val; |
|---|
| 1038 | } |
|---|
| 1039 | sei_read_code( pDecodedMessageOutputStream, 8, val, "exposure_index_idc" ); sei.m_exposureIndexIdc = val; |
|---|
| 1040 | if( sei.m_exposureIndexIdc == 255) //Extended_ISO |
|---|
| 1041 | { |
|---|
| 1042 | sei_read_code( pDecodedMessageOutputStream, 32, val, "exposure_index_value" ); sei.m_exposureIndexValue = val; |
|---|
| 1043 | } |
|---|
| 1044 | sei_read_flag( pDecodedMessageOutputStream, val, "exposure_compensation_value_sign_flag" ); sei.m_exposureCompensationValueSignFlag = val; |
|---|
| 1045 | sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_numerator" ); sei.m_exposureCompensationValueNumerator = val; |
|---|
| 1046 | sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_denom_idc" ); sei.m_exposureCompensationValueDenomIdc = val; |
|---|
| 1047 | sei_read_code( pDecodedMessageOutputStream, 32, val, "ref_screen_luminance_white" ); sei.m_refScreenLuminanceWhite = val; |
|---|
| 1048 | sei_read_code( pDecodedMessageOutputStream, 32, val, "extended_range_white_level" ); sei.m_extendedRangeWhiteLevel = val; |
|---|
| 1049 | sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_black_level_code_value" ); sei.m_nominalBlackLevelLumaCodeValue = val; |
|---|
| 1050 | sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_white_level_code_value" ); sei.m_nominalWhiteLevelLumaCodeValue= val; |
|---|
| 1051 | sei_read_code( pDecodedMessageOutputStream, 16, val, "extended_white_level_code_value" ); sei.m_extendedWhiteLevelLumaCodeValue = val; |
|---|
| 1052 | break; |
|---|
| 1053 | } |
|---|
| 1054 | default: |
|---|
| 1055 | { |
|---|
| 1056 | assert(!"Undefined SEIToneMapModelId"); |
|---|
| 1057 | break; |
|---|
| 1058 | } |
|---|
| 1059 | }//switch model id |
|---|
| 1060 | }// if(!sei.m_toneMapCancelFlag) |
|---|
| 1061 | } |
|---|
| 1062 | |
|---|
| 1063 | Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1064 | { |
|---|
| 1065 | Int iCode; |
|---|
| 1066 | UInt uiCode; |
|---|
| 1067 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1068 | |
|---|
| 1069 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "sop_seq_parameter_set_id" ); sei.m_sopSeqParameterSetId = uiCode; |
|---|
| 1070 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_pics_in_sop_minus1" ); sei.m_numPicsInSopMinus1 = uiCode; |
|---|
| 1071 | for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++) |
|---|
| 1072 | { |
|---|
| 1073 | sei_read_code( pDecodedMessageOutputStream, 6, uiCode, "sop_vcl_nut[i]" ); sei.m_sopDescVclNaluType[i] = uiCode; |
|---|
| 1074 | sei_read_code( pDecodedMessageOutputStream, 3, sei.m_sopDescTemporalId[i], "sop_temporal_id[i]" ); sei.m_sopDescTemporalId[i] = uiCode; |
|---|
| 1075 | if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP) |
|---|
| 1076 | { |
|---|
| 1077 | sei_read_uvlc( pDecodedMessageOutputStream, sei.m_sopDescStRpsIdx[i], "sop_short_term_rps_idx[i]" ); sei.m_sopDescStRpsIdx[i] = uiCode; |
|---|
| 1078 | } |
|---|
| 1079 | if (i > 0) |
|---|
| 1080 | { |
|---|
| 1081 | sei_read_svlc( pDecodedMessageOutputStream, iCode, "sop_poc_delta[i]" ); sei.m_sopDescPocDelta[i] = iCode; |
|---|
| 1082 | } |
|---|
| 1083 | } |
|---|
| 1084 | } |
|---|
| 1085 | |
|---|
| 1086 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 1087 | Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1088 | #else |
|---|
| 1089 | Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1090 | #endif |
|---|
| 1091 | { |
|---|
| 1092 | UInt uiCode; |
|---|
| 1093 | SEIMessages seis; |
|---|
| 1094 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1095 | |
|---|
| 1096 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "bitstream_subset_flag" ); sei.m_bitStreamSubsetFlag = uiCode; |
|---|
| 1097 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "nesting_op_flag" ); sei.m_nestingOpFlag = uiCode; |
|---|
| 1098 | if (sei.m_nestingOpFlag) |
|---|
| 1099 | { |
|---|
| 1100 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "default_op_flag" ); sei.m_defaultOpFlag = uiCode; |
|---|
| 1101 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_num_ops_minus1" ); sei.m_nestingNumOpsMinus1 = uiCode; |
|---|
| 1102 | for (UInt i = sei.m_defaultOpFlag; i <= sei.m_nestingNumOpsMinus1; i++) |
|---|
| 1103 | { |
|---|
| 1104 | sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "nesting_max_temporal_id_plus1[i]" ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode; |
|---|
| 1105 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_op_idx[i]" ); sei.m_nestingOpIdx[i] = uiCode; |
|---|
| 1106 | } |
|---|
| 1107 | } |
|---|
| 1108 | else |
|---|
| 1109 | { |
|---|
| 1110 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "all_layers_flag" ); sei.m_allLayersFlag = uiCode; |
|---|
| 1111 | if (!sei.m_allLayersFlag) |
|---|
| 1112 | { |
|---|
| 1113 | sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "nesting_no_op_max_temporal_id_plus1" ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode; |
|---|
| 1114 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_num_layers_minus1" ); sei.m_nestingNumLayersMinus1 = uiCode; |
|---|
| 1115 | for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++) |
|---|
| 1116 | { |
|---|
| 1117 | sei_read_code( pDecodedMessageOutputStream, 6, uiCode, "nesting_layer_id[i]" ); sei.m_nestingLayerId[i] = uiCode; |
|---|
| 1118 | } |
|---|
| 1119 | } |
|---|
| 1120 | } |
|---|
| 1121 | |
|---|
| 1122 | // byte alignment |
|---|
| 1123 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
|---|
| 1124 | { |
|---|
| 1125 | UInt code; |
|---|
| 1126 | sei_read_flag( pDecodedMessageOutputStream, code, "nesting_zero_bit" ); |
|---|
| 1127 | } |
|---|
| 1128 | |
|---|
| 1129 | sei.m_callerOwnsSEIs = false; |
|---|
| 1130 | |
|---|
| 1131 | // read nested SEI messages |
|---|
| 1132 | do { |
|---|
| 1133 | #if O0164_MULTI_LAYER_HRD |
|---|
| 1134 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 1135 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream, &sei); |
|---|
| 1136 | #else |
|---|
| 1137 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream, &sei); |
|---|
| 1138 | #endif |
|---|
| 1139 | #else |
|---|
| 1140 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 1141 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream); |
|---|
| 1142 | #else |
|---|
| 1143 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream); |
|---|
| 1144 | #endif |
|---|
| 1145 | #endif |
|---|
| 1146 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
|---|
| 1147 | |
|---|
| 1148 | if (pDecodedMessageOutputStream) (*pDecodedMessageOutputStream) << "End of scalable nesting SEI message\n"; |
|---|
| 1149 | } |
|---|
| 1150 | |
|---|
| 1151 | Void SEIReader::xParseSEITempMotionConstraintsTileSets(SEITempMotionConstrainedTileSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1152 | { |
|---|
| 1153 | UInt code; |
|---|
| 1154 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1155 | 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); |
|---|
| 1156 | sei_read_flag( pDecodedMessageOutputStream, code, "each_tile_one_tile_set_flag"); sei.m_each_tile_one_tile_set_flag = (code != 0); |
|---|
| 1157 | |
|---|
| 1158 | if(!sei.m_each_tile_one_tile_set_flag) |
|---|
| 1159 | { |
|---|
| 1160 | sei_read_flag( pDecodedMessageOutputStream, code, "limited_tile_set_display_flag"); sei.m_limited_tile_set_display_flag = (code != 0); |
|---|
| 1161 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_sets_in_message_minus1"); sei.setNumberOfTileSets(code + 1); |
|---|
| 1162 | |
|---|
| 1163 | if(sei.getNumberOfTileSets() != 0) |
|---|
| 1164 | { |
|---|
| 1165 | for(Int i = 0; i < sei.getNumberOfTileSets(); i++) |
|---|
| 1166 | { |
|---|
| 1167 | sei_read_uvlc( pDecodedMessageOutputStream, code, "mcts_id"); sei.tileSetData(i).m_mcts_id = code; |
|---|
| 1168 | |
|---|
| 1169 | if(sei.m_limited_tile_set_display_flag) |
|---|
| 1170 | { |
|---|
| 1171 | sei_read_flag( pDecodedMessageOutputStream, code, "display_tile_set_flag"); sei.tileSetData(i).m_display_tile_set_flag = (code != 1); |
|---|
| 1172 | } |
|---|
| 1173 | |
|---|
| 1174 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_tile_rects_in_set_minus1"); sei.tileSetData(i).setNumberOfTileRects(code + 1); |
|---|
| 1175 | |
|---|
| 1176 | for(Int j=0; j<sei.tileSetData(i).getNumberOfTileRects(); j++) |
|---|
| 1177 | { |
|---|
| 1178 | sei_read_uvlc( pDecodedMessageOutputStream, code, "top_left_tile_index"); sei.tileSetData(i).topLeftTileIndex(j) = code; |
|---|
| 1179 | sei_read_uvlc( pDecodedMessageOutputStream, code, "bottom_right_tile_index"); sei.tileSetData(i).bottomRightTileIndex(j) = code; |
|---|
| 1180 | } |
|---|
| 1181 | |
|---|
| 1182 | if(!sei.m_mc_all_tiles_exact_sample_value_match_flag) |
|---|
| 1183 | { |
|---|
| 1184 | sei_read_flag( pDecodedMessageOutputStream, code, "exact_sample_value_match_flag"); sei.tileSetData(i).m_exact_sample_value_match_flag = (code != 0); |
|---|
| 1185 | } |
|---|
| 1186 | sei_read_flag( pDecodedMessageOutputStream, code, "mcts_tier_level_idc_present_flag"); sei.tileSetData(i).m_mcts_tier_level_idc_present_flag = (code != 0); |
|---|
| 1187 | |
|---|
| 1188 | if(sei.tileSetData(i).m_mcts_tier_level_idc_present_flag) |
|---|
| 1189 | { |
|---|
| 1190 | sei_read_flag( pDecodedMessageOutputStream, code, "mcts_tier_flag"); sei.tileSetData(i).m_mcts_tier_flag = (code != 0); |
|---|
| 1191 | sei_read_code( pDecodedMessageOutputStream, 8, code, "mcts_level_idc"); sei.tileSetData(i).m_mcts_level_idc = code; |
|---|
| 1192 | } |
|---|
| 1193 | } |
|---|
| 1194 | } |
|---|
| 1195 | } |
|---|
| 1196 | else |
|---|
| 1197 | { |
|---|
| 1198 | sei_read_flag( pDecodedMessageOutputStream, code, "max_mcs_tier_level_idc_present_flag"); sei.m_max_mcs_tier_level_idc_present_flag = code; |
|---|
| 1199 | if(sei.m_max_mcs_tier_level_idc_present_flag) |
|---|
| 1200 | { |
|---|
| 1201 | sei_read_flag( pDecodedMessageOutputStream, code, "max_mcts_tier_flag"); sei.m_max_mcts_tier_flag = code; |
|---|
| 1202 | sei_read_code( pDecodedMessageOutputStream, 8, code, "max_mcts_level_idc"); sei.m_max_mcts_level_idc = code; |
|---|
| 1203 | } |
|---|
| 1204 | } |
|---|
| 1205 | } |
|---|
| 1206 | |
|---|
| 1207 | Void SEIReader::xParseSEITimeCode(SEITimeCode& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1208 | { |
|---|
| 1209 | UInt code; |
|---|
| 1210 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1211 | sei_read_code( pDecodedMessageOutputStream, 2, code, "num_clock_ts"); sei.numClockTs = code; |
|---|
| 1212 | for(Int i = 0; i < sei.numClockTs; i++) |
|---|
| 1213 | { |
|---|
| 1214 | TComSEITimeSet currentTimeSet; |
|---|
| 1215 | sei_read_flag( pDecodedMessageOutputStream, code, "clock_time_stamp_flag[i]"); currentTimeSet.clockTimeStampFlag = code; |
|---|
| 1216 | if(currentTimeSet.clockTimeStampFlag) |
|---|
| 1217 | { |
|---|
| 1218 | sei_read_flag( pDecodedMessageOutputStream, code, "nuit_field_based_flag"); currentTimeSet.numUnitFieldBasedFlag = code; |
|---|
| 1219 | sei_read_code( pDecodedMessageOutputStream, 5, code, "counting_type"); currentTimeSet.countingType = code; |
|---|
| 1220 | sei_read_flag( pDecodedMessageOutputStream, code, "full_timestamp_flag"); currentTimeSet.fullTimeStampFlag = code; |
|---|
| 1221 | sei_read_flag( pDecodedMessageOutputStream, code, "discontinuity_flag"); currentTimeSet.discontinuityFlag = code; |
|---|
| 1222 | sei_read_flag( pDecodedMessageOutputStream, code, "cnt_dropped_flag"); currentTimeSet.cntDroppedFlag = code; |
|---|
| 1223 | sei_read_code( pDecodedMessageOutputStream, 9, code, "n_frames"); currentTimeSet.numberOfFrames = code; |
|---|
| 1224 | if(currentTimeSet.fullTimeStampFlag) |
|---|
| 1225 | { |
|---|
| 1226 | sei_read_code( pDecodedMessageOutputStream, 6, code, "seconds_value"); currentTimeSet.secondsValue = code; |
|---|
| 1227 | sei_read_code( pDecodedMessageOutputStream, 6, code, "minutes_value"); currentTimeSet.minutesValue = code; |
|---|
| 1228 | sei_read_code( pDecodedMessageOutputStream, 5, code, "hours_value"); currentTimeSet.hoursValue = code; |
|---|
| 1229 | } |
|---|
| 1230 | else |
|---|
| 1231 | { |
|---|
| 1232 | sei_read_flag( pDecodedMessageOutputStream, code, "seconds_flag"); currentTimeSet.secondsFlag = code; |
|---|
| 1233 | if(currentTimeSet.secondsFlag) |
|---|
| 1234 | { |
|---|
| 1235 | sei_read_code( pDecodedMessageOutputStream, 6, code, "seconds_value"); currentTimeSet.secondsValue = code; |
|---|
| 1236 | sei_read_flag( pDecodedMessageOutputStream, code, "minutes_flag"); currentTimeSet.minutesFlag = code; |
|---|
| 1237 | if(currentTimeSet.minutesFlag) |
|---|
| 1238 | { |
|---|
| 1239 | sei_read_code( pDecodedMessageOutputStream, 6, code, "minutes_value"); currentTimeSet.minutesValue = code; |
|---|
| 1240 | sei_read_flag( pDecodedMessageOutputStream, code, "hours_flag"); currentTimeSet.hoursFlag = code; |
|---|
| 1241 | if(currentTimeSet.hoursFlag) |
|---|
| 1242 | sei_read_code( pDecodedMessageOutputStream, 5, code, "hours_value"); currentTimeSet.hoursValue = code; |
|---|
| 1243 | } |
|---|
| 1244 | } |
|---|
| 1245 | } |
|---|
| 1246 | sei_read_code( pDecodedMessageOutputStream, 5, code, "time_offset_length"); currentTimeSet.timeOffsetLength = code; |
|---|
| 1247 | if(currentTimeSet.timeOffsetLength > 0) |
|---|
| 1248 | { |
|---|
| 1249 | sei_read_code( pDecodedMessageOutputStream, currentTimeSet.timeOffsetLength, code, "time_offset_value"); |
|---|
| 1250 | if((code & (1 << (currentTimeSet.timeOffsetLength-1))) == 0) |
|---|
| 1251 | { |
|---|
| 1252 | currentTimeSet.timeOffsetValue = code; |
|---|
| 1253 | } |
|---|
| 1254 | else |
|---|
| 1255 | { |
|---|
| 1256 | code &= (1<< (currentTimeSet.timeOffsetLength-1)) - 1; |
|---|
| 1257 | currentTimeSet.timeOffsetValue = ~code + 1; |
|---|
| 1258 | } |
|---|
| 1259 | } |
|---|
| 1260 | } |
|---|
| 1261 | sei.timeSetArray[i] = currentTimeSet; |
|---|
| 1262 | } |
|---|
| 1263 | } |
|---|
| 1264 | |
|---|
| 1265 | Void SEIReader::xParseSEIChromaSamplingFilterHint(SEIChromaSamplingFilterHint& sei, UInt payloadSize/*, TComSPS* sps*/, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1266 | { |
|---|
| 1267 | UInt uiCode; |
|---|
| 1268 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1269 | |
|---|
| 1270 | sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "ver_chroma_filter_idc"); sei.m_verChromaFilterIdc = uiCode; |
|---|
| 1271 | sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "hor_chroma_filter_idc"); sei.m_horChromaFilterIdc = uiCode; |
|---|
| 1272 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "ver_filtering_process_flag"); sei.m_verFilteringProcessFlag = uiCode; |
|---|
| 1273 | if(sei.m_verChromaFilterIdc == 1 || sei.m_horChromaFilterIdc == 1) |
|---|
| 1274 | { |
|---|
| 1275 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "target_format_idc"); sei.m_targetFormatIdc = uiCode; |
|---|
| 1276 | if(sei.m_verChromaFilterIdc == 1) |
|---|
| 1277 | { |
|---|
| 1278 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_vertical_filters"); sei.m_numVerticalFilters = uiCode; |
|---|
| 1279 | if(sei.m_numVerticalFilters > 0) |
|---|
| 1280 | { |
|---|
| 1281 | sei.m_verTapLengthMinus1 = (Int*)malloc(sei.m_numVerticalFilters * sizeof(Int)); |
|---|
| 1282 | sei.m_verFilterCoeff = (Int**)malloc(sei.m_numVerticalFilters * sizeof(Int*)); |
|---|
| 1283 | for(Int i = 0; i < sei.m_numVerticalFilters; i ++) |
|---|
| 1284 | { |
|---|
| 1285 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "ver_tap_length_minus_1"); sei.m_verTapLengthMinus1[i] = uiCode; |
|---|
| 1286 | sei.m_verFilterCoeff[i] = (Int*)malloc(sei.m_verTapLengthMinus1[i] * sizeof(Int)); |
|---|
| 1287 | for(Int j = 0; j < sei.m_verTapLengthMinus1[i]; j ++) |
|---|
| 1288 | { |
|---|
| 1289 | sei_read_svlc( pDecodedMessageOutputStream, sei.m_verFilterCoeff[i][j], "ver_filter_coeff"); |
|---|
| 1290 | } |
|---|
| 1291 | } |
|---|
| 1292 | } |
|---|
| 1293 | } |
|---|
| 1294 | if(sei.m_horChromaFilterIdc == 1) |
|---|
| 1295 | { |
|---|
| 1296 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_horizontal_filters"); sei.m_numHorizontalFilters = uiCode; |
|---|
| 1297 | if(sei.m_numHorizontalFilters > 0) |
|---|
| 1298 | { |
|---|
| 1299 | sei.m_horTapLengthMinus1 = (Int*)malloc(sei.m_numHorizontalFilters * sizeof(Int)); |
|---|
| 1300 | sei.m_horFilterCoeff = (Int**)malloc(sei.m_numHorizontalFilters * sizeof(Int*)); |
|---|
| 1301 | for(Int i = 0; i < sei.m_numHorizontalFilters; i ++) |
|---|
| 1302 | { |
|---|
| 1303 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "hor_tap_length_minus_1"); sei.m_horTapLengthMinus1[i] = uiCode; |
|---|
| 1304 | sei.m_horFilterCoeff[i] = (Int*)malloc(sei.m_horTapLengthMinus1[i] * sizeof(Int)); |
|---|
| 1305 | for(Int j = 0; j < sei.m_horTapLengthMinus1[i]; j ++) |
|---|
| 1306 | { |
|---|
| 1307 | sei_read_svlc( pDecodedMessageOutputStream, sei.m_horFilterCoeff[i][j], "hor_filter_coeff"); |
|---|
| 1308 | } |
|---|
| 1309 | } |
|---|
| 1310 | } |
|---|
| 1311 | } |
|---|
| 1312 | } |
|---|
| 1313 | } |
|---|
| 1314 | |
|---|
| 1315 | Void SEIReader::xParseSEIKneeFunctionInfo(SEIKneeFunctionInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1316 | { |
|---|
| 1317 | Int i; |
|---|
| 1318 | UInt val; |
|---|
| 1319 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1320 | |
|---|
| 1321 | sei_read_uvlc( pDecodedMessageOutputStream, val, "knee_function_id" ); sei.m_kneeId = val; |
|---|
| 1322 | sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_cancel_flag" ); sei.m_kneeCancelFlag = val; |
|---|
| 1323 | if ( !sei.m_kneeCancelFlag ) |
|---|
| 1324 | { |
|---|
| 1325 | sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_persistence_flag" ); sei.m_kneePersistenceFlag = val; |
|---|
| 1326 | sei_read_code( pDecodedMessageOutputStream, 32, val, "input_d_range" ); sei.m_kneeInputDrange = val; |
|---|
| 1327 | sei_read_code( pDecodedMessageOutputStream, 32, val, "input_disp_luminance" ); sei.m_kneeInputDispLuminance = val; |
|---|
| 1328 | sei_read_code( pDecodedMessageOutputStream, 32, val, "output_d_range" ); sei.m_kneeOutputDrange = val; |
|---|
| 1329 | sei_read_code( pDecodedMessageOutputStream, 32, val, "output_disp_luminance" ); sei.m_kneeOutputDispLuminance = val; |
|---|
| 1330 | sei_read_uvlc( pDecodedMessageOutputStream, val, "num_knee_points_minus1" ); sei.m_kneeNumKneePointsMinus1 = val; |
|---|
| 1331 | assert( sei.m_kneeNumKneePointsMinus1 > 0 ); |
|---|
| 1332 | sei.m_kneeInputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1); |
|---|
| 1333 | sei.m_kneeOutputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1); |
|---|
| 1334 | for(i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ ) |
|---|
| 1335 | { |
|---|
| 1336 | sei_read_code( pDecodedMessageOutputStream, 10, val, "input_knee_point" ); sei.m_kneeInputKneePoint[i] = val; |
|---|
| 1337 | sei_read_code( pDecodedMessageOutputStream, 10, val, "output_knee_point" ); sei.m_kneeOutputKneePoint[i] = val; |
|---|
| 1338 | } |
|---|
| 1339 | } |
|---|
| 1340 | } |
|---|
| 1341 | |
|---|
| 1342 | Void SEIReader::xParseSEIMasteringDisplayColourVolume(SEIMasteringDisplayColourVolume& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1343 | { |
|---|
| 1344 | UInt code; |
|---|
| 1345 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
|---|
| 1346 | |
|---|
| 1347 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[0]" ); sei.values.primaries[0][0] = code; |
|---|
| 1348 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[0]" ); sei.values.primaries[0][1] = code; |
|---|
| 1349 | |
|---|
| 1350 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[1]" ); sei.values.primaries[1][0] = code; |
|---|
| 1351 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[1]" ); sei.values.primaries[1][1] = code; |
|---|
| 1352 | |
|---|
| 1353 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[2]" ); sei.values.primaries[2][0] = code; |
|---|
| 1354 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[2]" ); sei.values.primaries[2][1] = code; |
|---|
| 1355 | |
|---|
| 1356 | |
|---|
| 1357 | sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_x" ); sei.values.whitePoint[0] = code; |
|---|
| 1358 | sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_y" ); sei.values.whitePoint[1] = code; |
|---|
| 1359 | |
|---|
| 1360 | sei_read_code( pDecodedMessageOutputStream, 32, code, "max_display_mastering_luminance" ); sei.values.maxLuminance = code; |
|---|
| 1361 | sei_read_code( pDecodedMessageOutputStream, 32, code, "min_display_mastering_luminance" ); sei.values.minLuminance = code; |
|---|
| 1362 | } |
|---|
| 1363 | |
|---|
| 1364 | #if Q0074_COLOUR_REMAPPING_SEI |
|---|
| 1365 | Void SEIReader::xParseSEIColourRemappingInfo(SEIColourRemappingInfo& sei, UInt /*payloadSize*/, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1366 | { |
|---|
| 1367 | UInt uiVal; |
|---|
| 1368 | Int iVal; |
|---|
| 1369 | |
|---|
| 1370 | sei_read_uvlc( pDecodedMessageOutputStream, uiVal, "colour_remap_id" ); sei.m_colourRemapId = uiVal; |
|---|
| 1371 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_cancel_flag" ); sei.m_colourRemapCancelFlag = uiVal; |
|---|
| 1372 | if( !sei.m_colourRemapCancelFlag ) |
|---|
| 1373 | { |
|---|
| 1374 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_persistence_flag" ); sei.m_colourRemapPersistenceFlag = uiVal; |
|---|
| 1375 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_video_signal_info_present_flag" ); sei.m_colourRemapVideoSignalInfoPresentFlag = uiVal; |
|---|
| 1376 | if ( sei.m_colourRemapVideoSignalInfoPresentFlag ) |
|---|
| 1377 | { |
|---|
| 1378 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_full_range_flag" ); sei.m_colourRemapFullRangeFlag = uiVal; |
|---|
| 1379 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_primaries" ); sei.m_colourRemapPrimaries = uiVal; |
|---|
| 1380 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_transfer_function" ); sei.m_colourRemapTransferFunction = uiVal; |
|---|
| 1381 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_matrix_coefficients" ); sei.m_colourRemapMatrixCoefficients = uiVal; |
|---|
| 1382 | } |
|---|
| 1383 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_input_bit_depth" ); sei.m_colourRemapInputBitDepth = uiVal; |
|---|
| 1384 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_bit_depth" ); sei.m_colourRemapBitDepth = uiVal; |
|---|
| 1385 | |
|---|
| 1386 | for( Int c=0 ; c<3 ; c++ ) |
|---|
| 1387 | { |
|---|
| 1388 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "pre_lut_num_val_minus1[c]" ); sei.m_preLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; |
|---|
| 1389 | sei.m_preLutCodedValue[c].resize(sei.m_preLutNumValMinus1[c]+1); |
|---|
| 1390 | sei.m_preLutTargetValue[c].resize(sei.m_preLutNumValMinus1[c]+1); |
|---|
| 1391 | if( uiVal> 0 ) |
|---|
| 1392 | for ( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ ) |
|---|
| 1393 | { |
|---|
| 1394 | sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_coded_value[c][i]" ); sei.m_preLutCodedValue[c][i] = uiVal; |
|---|
| 1395 | sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_target_value[c][i]" ); sei.m_preLutTargetValue[c][i] = uiVal; |
|---|
| 1396 | } |
|---|
| 1397 | else // pre_lut_num_val_minus1[c] == 0 |
|---|
| 1398 | { |
|---|
| 1399 | sei.m_preLutCodedValue[c][0] = 0; |
|---|
| 1400 | sei.m_preLutTargetValue[c][0] = 0; |
|---|
| 1401 | sei.m_preLutCodedValue[c][1] = (1 << sei.m_colourRemapInputBitDepth) - 1 ; |
|---|
| 1402 | sei.m_preLutTargetValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1 ; |
|---|
| 1403 | } |
|---|
| 1404 | } |
|---|
| 1405 | |
|---|
| 1406 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_matrix_present_flag" ); sei.m_colourRemapMatrixPresentFlag = uiVal; |
|---|
| 1407 | if( sei.m_colourRemapMatrixPresentFlag ) |
|---|
| 1408 | { |
|---|
| 1409 | sei_read_code( pDecodedMessageOutputStream, 4, uiVal, "log2_matrix_denom" ); sei.m_log2MatrixDenom = uiVal; |
|---|
| 1410 | for ( Int c=0 ; c<3 ; c++ ) |
|---|
| 1411 | for ( Int i=0 ; i<3 ; i++ ) |
|---|
| 1412 | { |
|---|
| 1413 | sei_read_svlc( pDecodedMessageOutputStream, iVal, "colour_remap_coeffs[c][i]" ); sei.m_colourRemapCoeffs[c][i] = iVal; |
|---|
| 1414 | } |
|---|
| 1415 | } |
|---|
| 1416 | else // setting default matrix (I3) |
|---|
| 1417 | { |
|---|
| 1418 | sei.m_log2MatrixDenom = 0; |
|---|
| 1419 | for ( Int c=0 ; c<3 ; c++ ) |
|---|
| 1420 | for ( Int i=0 ; i<3 ; i++ ) |
|---|
| 1421 | sei.m_colourRemapCoeffs[c][i] = (c==i) ? 1 : 0; |
|---|
| 1422 | } |
|---|
| 1423 | for( Int c=0 ; c<3 ; c++ ) |
|---|
| 1424 | { |
|---|
| 1425 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "post_lut_num_val_minus1[c]" ); sei.m_postLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; |
|---|
| 1426 | sei.m_postLutCodedValue[c].resize(sei.m_postLutNumValMinus1[c]+1); |
|---|
| 1427 | sei.m_postLutTargetValue[c].resize(sei.m_postLutNumValMinus1[c]+1); |
|---|
| 1428 | if( uiVal > 0 ) |
|---|
| 1429 | for ( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ ) |
|---|
| 1430 | { |
|---|
| 1431 | sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_coded_value[c][i]" ); sei.m_postLutCodedValue[c][i] = uiVal; |
|---|
| 1432 | sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_target_value[c][i]" ); sei.m_postLutTargetValue[c][i] = uiVal; |
|---|
| 1433 | } |
|---|
| 1434 | else |
|---|
| 1435 | { |
|---|
| 1436 | sei.m_postLutCodedValue[c][0] = 0; |
|---|
| 1437 | sei.m_postLutTargetValue[c][0] = 0; |
|---|
| 1438 | sei.m_postLutTargetValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1; |
|---|
| 1439 | sei.m_postLutCodedValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1; |
|---|
| 1440 | } |
|---|
| 1441 | } |
|---|
| 1442 | } |
|---|
| 1443 | } |
|---|
| 1444 | #endif |
|---|
| 1445 | |
|---|
| 1446 | |
|---|
| 1447 | #if SVC_EXTENSION |
|---|
| 1448 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 1449 | Void SEIReader::xParseSEILayersNotPresent(SEILayersNotPresent &sei, UInt payloadSize, TComVPS *vps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1450 | { |
|---|
| 1451 | UInt uiCode; |
|---|
| 1452 | UInt i = 0; |
|---|
| 1453 | |
|---|
| 1454 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "lp_sei_active_vps_id" ); sei.m_activeVpsId = uiCode; |
|---|
| 1455 | assert(vps->getVPSId() == sei.m_activeVpsId); |
|---|
| 1456 | sei.m_vpsMaxLayers = vps->getMaxLayers(); |
|---|
| 1457 | for (; i < sei.m_vpsMaxLayers; i++) |
|---|
| 1458 | { |
|---|
| 1459 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "layer_not_present_flag" ); sei.m_layerNotPresentFlag[i] = uiCode ? true : false; |
|---|
| 1460 | } |
|---|
| 1461 | for (; i < MAX_LAYERS; i++) |
|---|
| 1462 | { |
|---|
| 1463 | sei.m_layerNotPresentFlag[i] = false; |
|---|
| 1464 | } |
|---|
| 1465 | } |
|---|
| 1466 | #endif |
|---|
| 1467 | |
|---|
| 1468 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
|---|
| 1469 | Void SEIReader::xParseSEIInterLayerConstrainedTileSets (SEIInterLayerConstrainedTileSets &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1470 | { |
|---|
| 1471 | UInt uiCode; |
|---|
| 1472 | |
|---|
| 1473 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "il_all_tiles_exact_sample_value_match_flag" ); sei.m_ilAllTilesExactSampleValueMatchFlag = uiCode; |
|---|
| 1474 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "il_one_tile_per_tile_set_flag" ); sei.m_ilOneTilePerTileSetFlag = uiCode; |
|---|
| 1475 | if( !sei.m_ilOneTilePerTileSetFlag ) |
|---|
| 1476 | { |
|---|
| 1477 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_num_sets_in_message_minus1" ); sei.m_ilNumSetsInMessageMinus1 = uiCode; |
|---|
| 1478 | if( sei.m_ilNumSetsInMessageMinus1 ) |
|---|
| 1479 | { |
|---|
| 1480 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "skipped_tile_set_present_flag" ); sei.m_skippedTileSetPresentFlag = uiCode; |
|---|
| 1481 | } |
|---|
| 1482 | else |
|---|
| 1483 | { |
|---|
| 1484 | sei.m_skippedTileSetPresentFlag = false; |
|---|
| 1485 | } |
|---|
| 1486 | UInt numSignificantSets = sei.m_ilNumSetsInMessageMinus1 - (sei.m_skippedTileSetPresentFlag ? 1 : 0) + 1; |
|---|
| 1487 | for( UInt i = 0; i < numSignificantSets; i++ ) |
|---|
| 1488 | { |
|---|
| 1489 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "ilcts_id" ); sei.m_ilctsId[i] = uiCode; |
|---|
| 1490 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_num_tile_rects_in_set_minus1" ) ;sei.m_ilNumTileRectsInSetMinus1[i] = uiCode; |
|---|
| 1491 | for( UInt j = 0; j <= sei.m_ilNumTileRectsInSetMinus1[i]; j++ ) |
|---|
| 1492 | { |
|---|
| 1493 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_top_left_tile_index" ); sei.m_ilTopLeftTileIndex[i][j] = uiCode; |
|---|
| 1494 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_bottom_right_tile_index" ); sei.m_ilBottomRightTileIndex[i][j] = uiCode; |
|---|
| 1495 | } |
|---|
| 1496 | sei_read_code( pDecodedMessageOutputStream, 2, uiCode, "ilc_idc" ); sei.m_ilcIdc[i] = uiCode; |
|---|
| 1497 | if( sei.m_ilAllTilesExactSampleValueMatchFlag ) |
|---|
| 1498 | { |
|---|
| 1499 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "il_exact_sample_value_match_flag" ); sei.m_ilExactSampleValueMatchFlag[i] = uiCode; |
|---|
| 1500 | } |
|---|
| 1501 | } |
|---|
| 1502 | } |
|---|
| 1503 | else |
|---|
| 1504 | { |
|---|
| 1505 | sei_read_code( pDecodedMessageOutputStream, 2, uiCode, "all_tiles_ilc_idc" ); sei.m_allTilesIlcIdc = uiCode; |
|---|
| 1506 | } |
|---|
| 1507 | } |
|---|
| 1508 | #endif |
|---|
| 1509 | |
|---|
| 1510 | #if SUB_BITSTREAM_PROPERTY_SEI |
|---|
| 1511 | #if OLS_IDX_CHK |
|---|
| 1512 | Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei, TComVPS *vps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1513 | #else |
|---|
| 1514 | Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1515 | #endif |
|---|
| 1516 | { |
|---|
| 1517 | UInt uiCode; |
|---|
| 1518 | sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "active_vps_id" ); sei.m_activeVpsId = uiCode; |
|---|
| 1519 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_additional_sub_streams_minus1" ); sei.m_numAdditionalSubStreams = uiCode + 1; |
|---|
| 1520 | |
|---|
| 1521 | for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ ) |
|---|
| 1522 | { |
|---|
| 1523 | sei_read_code( pDecodedMessageOutputStream, 2, uiCode, "sub_bitstream_mode[i]" ); sei.m_subBitstreamMode[i] = uiCode; |
|---|
| 1524 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "output_layer_set_idx_to_vps[i]" ); |
|---|
| 1525 | #if OLS_IDX_CHK |
|---|
| 1526 | // The value of output_layer_set_idx_to_vps[ i ] shall be in the range of 0 to NumOutputLayerSets − 1, inclusive. |
|---|
| 1527 | assert(uiCode > 0 && uiCode <= vps->getNumOutputLayerSets()-1); |
|---|
| 1528 | #endif |
|---|
| 1529 | sei.m_outputLayerSetIdxToVps[i] = uiCode; |
|---|
| 1530 | sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "highest_sub_layer_id[i]" ); sei.m_highestSublayerId[i] = uiCode; |
|---|
| 1531 | sei_read_code( pDecodedMessageOutputStream, 16, uiCode, "avg_bit_rate[i]" ); sei.m_avgBitRate[i] = uiCode; |
|---|
| 1532 | sei_read_code( pDecodedMessageOutputStream, 16, uiCode, "max_bit_rate[i]" ); sei.m_maxBitRate[i] = uiCode; |
|---|
| 1533 | } |
|---|
| 1534 | } |
|---|
| 1535 | #endif |
|---|
| 1536 | |
|---|
| 1537 | #if O0164_MULTI_LAYER_HRD |
|---|
| 1538 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 1539 | Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1540 | #else |
|---|
| 1541 | Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, TComSPS *sps, const SEIScalableNesting &nestingSei, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1542 | #endif |
|---|
| 1543 | { |
|---|
| 1544 | UInt uiCode; |
|---|
| 1545 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "bsp_idx" ); sei.m_bspIdx = uiCode; |
|---|
| 1546 | |
|---|
| 1547 | // byte alignment |
|---|
| 1548 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
|---|
| 1549 | { |
|---|
| 1550 | UInt code; |
|---|
| 1551 | sei_read_flag( pDecodedMessageOutputStream, code, "bsp_nesting_zero_bit" ); |
|---|
| 1552 | } |
|---|
| 1553 | |
|---|
| 1554 | sei.m_callerOwnsSEIs = false; |
|---|
| 1555 | |
|---|
| 1556 | // read nested SEI messages |
|---|
| 1557 | #if NESTING_SEI_EXTENSIBILITY |
|---|
| 1558 | Int numSeiMessages = 0; |
|---|
| 1559 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_seis_in_bsp_minus1" ); assert( uiCode <= MAX_SEIS_IN_BSP_NESTING ); |
|---|
| 1560 | numSeiMessages = uiCode; |
|---|
| 1561 | for(Int i = 0; i < numSeiMessages; i++) |
|---|
| 1562 | { |
|---|
| 1563 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream, &nestingSei, &sei); |
|---|
| 1564 | } |
|---|
| 1565 | #else |
|---|
| 1566 | do { |
|---|
| 1567 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 1568 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream, &nestingSei, &sei); |
|---|
| 1569 | #else |
|---|
| 1570 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream, &nestingSei); |
|---|
| 1571 | #endif |
|---|
| 1572 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
|---|
| 1573 | #endif |
|---|
| 1574 | } |
|---|
| 1575 | |
|---|
| 1576 | Void SEIReader::xParseSEIBspInitialArrivalTime(SEIBspInitialArrivalTime &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1577 | { |
|---|
| 1578 | assert(vps->getVpsVuiPresentFlag()); |
|---|
| 1579 | |
|---|
| 1580 | #if VPS_VUI_BSP_HRD_PARAMS |
|---|
| 1581 | UInt uiCode; |
|---|
| 1582 | Int psIdx = bspNestingSei.m_seiPartitioningSchemeIdx; |
|---|
| 1583 | Int seiOlsIdx = bspNestingSei.m_seiOlsIdx; |
|---|
| 1584 | Int maxTemporalId = nestingSei.m_nestingMaxTemporalIdPlus1[0]; |
|---|
| 1585 | Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; |
|---|
| 1586 | std::vector<Int> hrdIdx(0, maxValues); |
|---|
| 1587 | std::vector<TComHRD *> hrdVec; |
|---|
| 1588 | std::vector<Int> syntaxElemLen; |
|---|
| 1589 | for(Int i = 0; i < maxValues; i++) |
|---|
| 1590 | { |
|---|
| 1591 | hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei.m_bspIdx); |
|---|
| 1592 | hrdVec[i] = vps->getBspHrd(hrdIdx[i]); |
|---|
| 1593 | |
|---|
| 1594 | syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; |
|---|
| 1595 | if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) |
|---|
| 1596 | { |
|---|
| 1597 | assert( syntaxElemLen[i] == 24 ); // Default value of init_cpb_removal_delay_length_minus1 is 23 |
|---|
| 1598 | } |
|---|
| 1599 | if( i > 0 ) |
|---|
| 1600 | { |
|---|
| 1601 | assert( hrdVec[i]->getNalHrdParametersPresentFlag() == hrdVec[i-1]->getNalHrdParametersPresentFlag() ); |
|---|
| 1602 | assert( hrdVec[i]->getVclHrdParametersPresentFlag() == hrdVec[i-1]->getVclHrdParametersPresentFlag() ); |
|---|
| 1603 | } |
|---|
| 1604 | } |
|---|
| 1605 | if (hrdVec[0]->getNalHrdParametersPresentFlag()) |
|---|
| 1606 | { |
|---|
| 1607 | for(UInt i = 0; i < maxValues; i++) |
|---|
| 1608 | { |
|---|
| 1609 | sei_read_code( pDecodedMessageOutputStream, syntaxElemLen[i], uiCode, "nal_initial_arrival_delay[i]" ); sei.m_nalInitialArrivalDelay[i] = uiCode; |
|---|
| 1610 | } |
|---|
| 1611 | } |
|---|
| 1612 | if( hrdVec[0]->getVclHrdParametersPresentFlag() ) |
|---|
| 1613 | { |
|---|
| 1614 | for(UInt i = 0; i < maxValues; i++) |
|---|
| 1615 | { |
|---|
| 1616 | sei_read_code( pDecodedMessageOutputStream, syntaxElemLen[i], uiCode, "vcl_initial_arrival_delay[i]" ); sei.m_vclInitialArrivalDelay[i] = uiCode; |
|---|
| 1617 | } |
|---|
| 1618 | } |
|---|
| 1619 | #else |
|---|
| 1620 | UInt schedCombCnt = vps->getNumBspSchedCombinations(nestingSei.m_nestingOpIdx[0]); |
|---|
| 1621 | UInt len; |
|---|
| 1622 | UInt hrdIdx; |
|---|
| 1623 | UInt uiCode; |
|---|
| 1624 | |
|---|
| 1625 | if (schedCombCnt > 0) |
|---|
| 1626 | { |
|---|
| 1627 | hrdIdx = vps->getBspCombHrdIdx(nestingSei.m_nestingOpIdx[0], 0, bspNestingSei.m_bspIdx); |
|---|
| 1628 | } |
|---|
| 1629 | else |
|---|
| 1630 | { |
|---|
| 1631 | hrdIdx = 0; |
|---|
| 1632 | } |
|---|
| 1633 | |
|---|
| 1634 | TComHRD *hrd = vps->getBspHrd(hrdIdx); |
|---|
| 1635 | |
|---|
| 1636 | if (hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag()) |
|---|
| 1637 | { |
|---|
| 1638 | len = hrd->getInitialCpbRemovalDelayLengthMinus1() + 1; |
|---|
| 1639 | } |
|---|
| 1640 | else |
|---|
| 1641 | { |
|---|
| 1642 | len = 23 + 1; |
|---|
| 1643 | } |
|---|
| 1644 | |
|---|
| 1645 | if (hrd->getNalHrdParametersPresentFlag()) |
|---|
| 1646 | { |
|---|
| 1647 | for(UInt i = 0; i < schedCombCnt; i++) |
|---|
| 1648 | { |
|---|
| 1649 | sei_read_code( pDecodedMessageOutputStream, len, uiCode, "nal_initial_arrival_delay" ); sei.m_nalInitialArrivalDelay[i] = uiCode; |
|---|
| 1650 | } |
|---|
| 1651 | } |
|---|
| 1652 | #if BSP_INIT_ARRIVAL_SEI |
|---|
| 1653 | if( hrd->getVclHrdParametersPresentFlag() ) |
|---|
| 1654 | #else |
|---|
| 1655 | else |
|---|
| 1656 | #endif |
|---|
| 1657 | { |
|---|
| 1658 | for(UInt i = 0; i < schedCombCnt; i++) |
|---|
| 1659 | { |
|---|
| 1660 | sei_read_code( pDecodedMessageOutputStream, len, uiCode, "vcl_initial_arrival_delay" ); sei.m_vclInitialArrivalDelay[i] = uiCode; |
|---|
| 1661 | } |
|---|
| 1662 | } |
|---|
| 1663 | #endif |
|---|
| 1664 | } |
|---|
| 1665 | |
|---|
| 1666 | #if !REMOVE_BSP_HRD_SEI |
|---|
| 1667 | Void SEIReader::xParseSEIBspHrd(SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1668 | { |
|---|
| 1669 | UInt uiCode; |
|---|
| 1670 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "sei_num_bsp_hrd_parameters_minus1" ); sei.m_seiNumBspHrdParametersMinus1 = uiCode; |
|---|
| 1671 | for (UInt i = 0; i <= sei.m_seiNumBspHrdParametersMinus1; i++) |
|---|
| 1672 | { |
|---|
| 1673 | if (i > 0) |
|---|
| 1674 | { |
|---|
| 1675 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "sei_bsp_cprms_present_flag" ); sei.m_seiBspCprmsPresentFlag[i] = uiCode; |
|---|
| 1676 | } |
|---|
| 1677 | xParseHrdParameters(sei.hrd, i==0 ? 1 : sei.m_seiBspCprmsPresentFlag[i], nestingSei.m_nestingMaxTemporalIdPlus1[0]-1); |
|---|
| 1678 | } |
|---|
| 1679 | for (UInt h = 0; h <= nestingSei.m_nestingNumOpsMinus1; h++) |
|---|
| 1680 | { |
|---|
| 1681 | UInt lsIdx = nestingSei.m_nestingOpIdx[h]; |
|---|
| 1682 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_sei_bitstream_partitions_minus1[i]"); sei.m_seiNumBitstreamPartitionsMinus1[lsIdx] = uiCode; |
|---|
| 1683 | #if HRD_BPB |
|---|
| 1684 | Int chkPart=0; |
|---|
| 1685 | #endif |
|---|
| 1686 | UInt i; |
|---|
| 1687 | for(i = 0; i <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; i++) |
|---|
| 1688 | { |
|---|
| 1689 | #if HRD_BPB |
|---|
| 1690 | UInt nl=0; UInt j; |
|---|
| 1691 | for(j = 0; j < sei.m_vpsMaxLayers; j++) |
|---|
| 1692 | { |
|---|
| 1693 | if (sei.m_layerIdIncludedFlag[lsIdx][j]) |
|---|
| 1694 | { |
|---|
| 1695 | nl++; |
|---|
| 1696 | } |
|---|
| 1697 | } |
|---|
| 1698 | for (j = 0; j < nl; j++) |
|---|
| 1699 | { |
|---|
| 1700 | #else |
|---|
| 1701 | for (UInt j = 0; j < sei.m_vpsMaxLayers; j++) |
|---|
| 1702 | { |
|---|
| 1703 | if (sei.m_layerIdIncludedFlag[lsIdx][j]) |
|---|
| 1704 | { |
|---|
| 1705 | #endif |
|---|
| 1706 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "sei_layer_in_bsp_flag[lsIdx][i][j]" ); sei.m_seiLayerInBspFlag[lsIdx][i][j] = uiCode; |
|---|
| 1707 | } |
|---|
| 1708 | #if !HRD_BPB |
|---|
| 1709 | } |
|---|
| 1710 | #endif |
|---|
| 1711 | #if HRD_BPB |
|---|
| 1712 | chkPart+=sei.m_seiLayerInBspFlag[lsIdx][i][j]; |
|---|
| 1713 | #endif |
|---|
| 1714 | } |
|---|
| 1715 | #if HRD_BPB |
|---|
| 1716 | assert(chkPart<=1); |
|---|
| 1717 | #endif |
|---|
| 1718 | #if HRD_BPB |
|---|
| 1719 | if(sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]==0) |
|---|
| 1720 | { |
|---|
| 1721 | Int chkPartition1=0; Int chkPartition2=0; |
|---|
| 1722 | for (UInt j = 0; j < sei.m_vpsMaxLayers; j++) |
|---|
| 1723 | { |
|---|
| 1724 | if( sei.m_layerIdIncludedFlag[lsIdx][j] ) |
|---|
| 1725 | { |
|---|
| 1726 | chkPartition1+=sei.m_seiLayerInBspFlag[lsIdx][0][j]; |
|---|
| 1727 | chkPartition2++; |
|---|
| 1728 | } |
|---|
| 1729 | } |
|---|
| 1730 | assert(chkPartition1!=chkPartition2); |
|---|
| 1731 | } |
|---|
| 1732 | #endif |
|---|
| 1733 | |
|---|
| 1734 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "sei_num_bsp_sched_combinations_minus1[i]"); sei.m_seiNumBspSchedCombinationsMinus1[lsIdx] = uiCode; |
|---|
| 1735 | for (i = 0; i <= sei.m_seiNumBspSchedCombinationsMinus1[lsIdx]; i++) |
|---|
| 1736 | { |
|---|
| 1737 | for (UInt j = 0; j <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; j++) |
|---|
| 1738 | { |
|---|
| 1739 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "sei_bsp_comb_hrd_idx[lsIdx][i][j]"); sei.m_seiBspCombHrdIdx[lsIdx][i][j] = uiCode; |
|---|
| 1740 | #if HRD_BPB |
|---|
| 1741 | assert(uiCode <= sei.m_seiNumBspHrdParametersMinus1); |
|---|
| 1742 | #endif |
|---|
| 1743 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "sei_bsp_comb_sched_idx[lsIdx][i][j]"); sei.m_seiBspCombScheddx[lsIdx][i][j] = uiCode; |
|---|
| 1744 | #if HRD_BPB |
|---|
| 1745 | assert(uiCode <= sei.hrd->getCpbCntMinus1( sps->getMaxTLayers()-1 )); |
|---|
| 1746 | #endif |
|---|
| 1747 | |
|---|
| 1748 | } |
|---|
| 1749 | } |
|---|
| 1750 | } |
|---|
| 1751 | } |
|---|
| 1752 | #endif |
|---|
| 1753 | |
|---|
| 1754 | Void SEIReader::xParseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1755 | { |
|---|
| 1756 | UInt uiCode; |
|---|
| 1757 | if( commonInfPresentFlag ) |
|---|
| 1758 | { |
|---|
| 1759 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
|---|
| 1760 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
|---|
| 1761 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
|---|
| 1762 | { |
|---|
| 1763 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
|---|
| 1764 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
|---|
| 1765 | { |
|---|
| 1766 | sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
|---|
| 1767 | sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
|---|
| 1768 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
|---|
| 1769 | sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
|---|
| 1770 | } |
|---|
| 1771 | sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
|---|
| 1772 | sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
|---|
| 1773 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
|---|
| 1774 | { |
|---|
| 1775 | sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
|---|
| 1776 | } |
|---|
| 1777 | sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
|---|
| 1778 | sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
|---|
| 1779 | sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
|---|
| 1780 | } |
|---|
| 1781 | } |
|---|
| 1782 | Int i, j, nalOrVcl; |
|---|
| 1783 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
|---|
| 1784 | { |
|---|
| 1785 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
|---|
| 1786 | if( !hrd->getFixedPicRateFlag( i ) ) |
|---|
| 1787 | { |
|---|
| 1788 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
|---|
| 1789 | } |
|---|
| 1790 | else |
|---|
| 1791 | { |
|---|
| 1792 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
|---|
| 1793 | } |
|---|
| 1794 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
|---|
| 1795 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
|---|
| 1796 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
|---|
| 1797 | { |
|---|
| 1798 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
|---|
| 1799 | } |
|---|
| 1800 | else |
|---|
| 1801 | { |
|---|
| 1802 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
|---|
| 1803 | } |
|---|
| 1804 | if (!hrd->getLowDelayHrdFlag( i )) |
|---|
| 1805 | { |
|---|
| 1806 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
|---|
| 1807 | } |
|---|
| 1808 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
|---|
| 1809 | { |
|---|
| 1810 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
|---|
| 1811 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
|---|
| 1812 | { |
|---|
| 1813 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
|---|
| 1814 | { |
|---|
| 1815 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
|---|
| 1816 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
|---|
| 1817 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
|---|
| 1818 | { |
|---|
| 1819 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
|---|
| 1820 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
|---|
| 1821 | } |
|---|
| 1822 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
|---|
| 1823 | } |
|---|
| 1824 | } |
|---|
| 1825 | } |
|---|
| 1826 | } |
|---|
| 1827 | } |
|---|
| 1828 | #endif |
|---|
| 1829 | |
|---|
| 1830 | #if Q0078_ADD_LAYER_SETS |
|---|
| 1831 | |
|---|
| 1832 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 1833 | Void SEIReader::xParseSEIOutputLayerSetNesting(SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1834 | #else |
|---|
| 1835 | Void SEIReader::xParseSEIOutputLayerSetNesting(SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1836 | #endif |
|---|
| 1837 | { |
|---|
| 1838 | UInt uiCode; |
|---|
| 1839 | SEIMessages seis; |
|---|
| 1840 | |
|---|
| 1841 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "ols_flag"); sei.m_olsFlag = uiCode; |
|---|
| 1842 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_ols_indices_minus1"); sei.m_numOlsIndicesMinus1 = uiCode; |
|---|
| 1843 | |
|---|
| 1844 | for (Int i = 0; i <= sei.m_numOlsIndicesMinus1; i++) |
|---|
| 1845 | { |
|---|
| 1846 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "ols_idx[i]"); sei.m_olsIdx[i] = uiCode; |
|---|
| 1847 | } |
|---|
| 1848 | |
|---|
| 1849 | // byte alignment |
|---|
| 1850 | while (m_pcBitstream->getNumBitsRead() % 8 != 0) |
|---|
| 1851 | { |
|---|
| 1852 | UInt code; |
|---|
| 1853 | sei_read_flag( pDecodedMessageOutputStream, code, "ols_nesting_zero_bit"); |
|---|
| 1854 | } |
|---|
| 1855 | |
|---|
| 1856 | sei.m_callerOwnsSEIs = false; |
|---|
| 1857 | |
|---|
| 1858 | // read nested SEI messages |
|---|
| 1859 | do { |
|---|
| 1860 | #if O0164_MULTI_LAYER_HRD |
|---|
| 1861 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 1862 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream); |
|---|
| 1863 | #else |
|---|
| 1864 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream); |
|---|
| 1865 | #endif |
|---|
| 1866 | #else |
|---|
| 1867 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 1868 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream); |
|---|
| 1869 | #else |
|---|
| 1870 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream); |
|---|
| 1871 | #endif |
|---|
| 1872 | #endif |
|---|
| 1873 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
|---|
| 1874 | |
|---|
| 1875 | } |
|---|
| 1876 | |
|---|
| 1877 | Void SEIReader::xParseSEIVPSRewriting(SEIVPSRewriting &sei, std::ostream *pDecodedMessageOutputStream ) |
|---|
| 1878 | { |
|---|
| 1879 | } |
|---|
| 1880 | |
|---|
| 1881 | #endif |
|---|
| 1882 | |
|---|
| 1883 | #if P0123_ALPHA_CHANNEL_SEI |
|---|
| 1884 | void SEIReader::xParseSEIAlphaChannelInfo(SEIAlphaChannelInfo &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1885 | { |
|---|
| 1886 | UInt value; |
|---|
| 1887 | sei_read_flag(pDecodedMessageOutputStream, value, "alpha_channel_cancel_flag"); sei.m_alphaChannelCancelFlag = value; |
|---|
| 1888 | if(!sei.m_alphaChannelCancelFlag) |
|---|
| 1889 | { |
|---|
| 1890 | sei_read_code(pDecodedMessageOutputStream, 3, value, "alpha_channel_use_idc"); sei.m_alphaChannelUseIdc = value; |
|---|
| 1891 | sei_read_code(pDecodedMessageOutputStream, 3, value, "alpha_channel_bit_depth_minus8"); sei.m_alphaChannelBitDepthMinus8 = value; |
|---|
| 1892 | sei_read_code(pDecodedMessageOutputStream, sei.m_alphaChannelBitDepthMinus8 + 9, value, "alpha_transparent_value"); sei.m_alphaTransparentValue = value; |
|---|
| 1893 | sei_read_code(pDecodedMessageOutputStream, sei.m_alphaChannelBitDepthMinus8 + 9, value, "alpha_opaque_value"); sei.m_alphaOpaqueValue = value; |
|---|
| 1894 | sei_read_flag(pDecodedMessageOutputStream, value, "alpha_channel_incr_flag"); sei.m_alphaChannelIncrFlag = value; |
|---|
| 1895 | sei_read_flag(pDecodedMessageOutputStream, value, "alpha_channel_clip_flag"); sei.m_alphaChannelClipFlag = value; |
|---|
| 1896 | if(sei.m_alphaChannelClipFlag) |
|---|
| 1897 | { |
|---|
| 1898 | sei_read_flag(pDecodedMessageOutputStream, value, "alpha_channel_clip_type_flag"); sei.m_alphaChannelClipTypeFlag = value; |
|---|
| 1899 | } |
|---|
| 1900 | } |
|---|
| 1901 | } |
|---|
| 1902 | #endif |
|---|
| 1903 | |
|---|
| 1904 | #if Q0096_OVERLAY_SEI |
|---|
| 1905 | Void SEIReader::xParseSEIOverlayInfo(SEIOverlayInfo& sei, UInt /*payloadSize*/, std::ostream *pDecodedMessageOutputStream) |
|---|
| 1906 | { |
|---|
| 1907 | Int i, j; |
|---|
| 1908 | UInt val; |
|---|
| 1909 | sei_read_flag( pDecodedMessageOutputStream, val, "overlay_info_cancel_flag" ); sei.m_overlayInfoCancelFlag = val; |
|---|
| 1910 | if ( !sei.m_overlayInfoCancelFlag ) |
|---|
| 1911 | { |
|---|
| 1912 | sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_content_aux_id_minus128" ); sei.m_overlayContentAuxIdMinus128 = val; |
|---|
| 1913 | sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_label_aux_id_minus128" ); sei.m_overlayLabelAuxIdMinus128 = val; |
|---|
| 1914 | sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_alpha_aux_id_minus128" ); sei.m_overlayAlphaAuxIdMinus128 = val; |
|---|
| 1915 | sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_element_label_value_length_minus8" ); sei.m_overlayElementLabelValueLengthMinus8 = val; |
|---|
| 1916 | sei_read_uvlc( pDecodedMessageOutputStream, val, "num_overlays_minus1" ); sei.m_numOverlaysMinus1 = val; |
|---|
| 1917 | |
|---|
| 1918 | assert( sei.m_numOverlaysMinus1 < MAX_OVERLAYS ); |
|---|
| 1919 | sei.m_overlayIdx.resize( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1920 | sei.m_languageOverlayPresentFlag.resize( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1921 | sei.m_overlayContentLayerId.resize( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1922 | sei.m_overlayLabelPresentFlag.resize( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1923 | sei.m_overlayLabelLayerId.resize( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1924 | sei.m_overlayAlphaPresentFlag.resize( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1925 | sei.m_overlayAlphaLayerId.resize( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1926 | sei.m_numOverlayElementsMinus1.resize( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1927 | sei.m_overlayElementLabelMin.resize( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1928 | sei.m_overlayElementLabelMax.resize( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1929 | for ( i=0 ; i<=sei.m_numOverlaysMinus1 ; i++ ) |
|---|
| 1930 | { |
|---|
| 1931 | sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_idx" ); sei.m_overlayIdx[i] = val; |
|---|
| 1932 | sei_read_flag( pDecodedMessageOutputStream, val, "language_overlay_present_flag" ); sei.m_languageOverlayPresentFlag[i] = val; |
|---|
| 1933 | sei_read_code( pDecodedMessageOutputStream, 6, val, "overlay_content_layer_id"); sei.m_overlayContentLayerId[i] = val; |
|---|
| 1934 | sei_read_flag( pDecodedMessageOutputStream, val, "overlay_label_present_flag" ); sei.m_overlayLabelPresentFlag[i] = val; |
|---|
| 1935 | if ( sei.m_overlayLabelPresentFlag[i] ) |
|---|
| 1936 | { |
|---|
| 1937 | sei_read_code( pDecodedMessageOutputStream, 6, val, "overlay_label_layer_id"); sei.m_overlayLabelLayerId[i] = val; |
|---|
| 1938 | } |
|---|
| 1939 | sei_read_flag( pDecodedMessageOutputStream, val, "overlay_alpha_present_flag" ); sei.m_overlayAlphaPresentFlag[i] = val; |
|---|
| 1940 | if ( sei.m_overlayAlphaPresentFlag[i] ) |
|---|
| 1941 | { |
|---|
| 1942 | sei_read_code( pDecodedMessageOutputStream, 6, val, "overlay_alpha_layer_id"); sei.m_overlayAlphaLayerId[i] = val; |
|---|
| 1943 | } |
|---|
| 1944 | if ( sei.m_overlayLabelPresentFlag[i] ) |
|---|
| 1945 | { |
|---|
| 1946 | sei_read_uvlc( pDecodedMessageOutputStream, val, "num_overlay_elements_minus1"); sei.m_numOverlayElementsMinus1[i] = val; |
|---|
| 1947 | assert( sei.m_numOverlayElementsMinus1[i] < MAX_OVERLAY_ELEMENTS ); |
|---|
| 1948 | sei.m_overlayElementLabelMin[i].resize( sei.m_numOverlayElementsMinus1[i]+1 ); |
|---|
| 1949 | sei.m_overlayElementLabelMax[i].resize( sei.m_numOverlayElementsMinus1[i]+1 ); |
|---|
| 1950 | for ( j=0 ; j<=sei.m_numOverlayElementsMinus1[i] ; j++ ) |
|---|
| 1951 | { |
|---|
| 1952 | sei_read_code( pDecodedMessageOutputStream, sei.m_overlayElementLabelValueLengthMinus8 + 8, val, "overlay_element_label_min"); sei.m_overlayElementLabelMin[i][j] = val; |
|---|
| 1953 | sei_read_code( pDecodedMessageOutputStream, sei.m_overlayElementLabelValueLengthMinus8 + 8, val, "overlay_element_label_max"); sei.m_overlayElementLabelMax[i][j] = val; |
|---|
| 1954 | } |
|---|
| 1955 | } |
|---|
| 1956 | else |
|---|
| 1957 | { |
|---|
| 1958 | sei.m_numOverlayElementsMinus1[i] = 0; |
|---|
| 1959 | } |
|---|
| 1960 | } |
|---|
| 1961 | |
|---|
| 1962 | // byte alignment |
|---|
| 1963 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
|---|
| 1964 | { |
|---|
| 1965 | sei_read_flag( pDecodedMessageOutputStream, val, "overlay_zero_bit" ); |
|---|
| 1966 | assert( val==0 ); |
|---|
| 1967 | } |
|---|
| 1968 | |
|---|
| 1969 | UChar* sval = new UChar[MAX_OVERLAY_STRING_BYTES]; |
|---|
| 1970 | UInt slen; |
|---|
| 1971 | sei.m_overlayLanguage.resize( sei.m_numOverlaysMinus1+1, NULL ); |
|---|
| 1972 | sei.m_overlayLanguageLength.resize( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1973 | sei.m_overlayName.resize( sei.m_numOverlaysMinus1+1, NULL ); |
|---|
| 1974 | sei.m_overlayNameLength.resize( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1975 | sei.m_overlayElementName.resize( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1976 | sei.m_overlayElementNameLength.resize( sei.m_numOverlaysMinus1+1 ); |
|---|
| 1977 | for ( i=0 ; i<=sei.m_numOverlaysMinus1 ; i++ ) |
|---|
| 1978 | { |
|---|
| 1979 | if ( sei.m_languageOverlayPresentFlag[i] ) |
|---|
| 1980 | { |
|---|
| 1981 | READ_STRING( MAX_OVERLAY_STRING_BYTES, sval, slen, "overlay_language" ); |
|---|
| 1982 | sei.m_overlayLanguage[i] = new UChar[slen]; |
|---|
| 1983 | memcpy(sei.m_overlayLanguage[i], sval, slen); |
|---|
| 1984 | sei.m_overlayLanguageLength[i] = slen; |
|---|
| 1985 | } |
|---|
| 1986 | READ_STRING( MAX_OVERLAY_STRING_BYTES, sval, slen, "overlay_name" ); |
|---|
| 1987 | sei.m_overlayName[i] = new UChar[slen]; |
|---|
| 1988 | memcpy(sei.m_overlayName[i], sval, slen); |
|---|
| 1989 | sei.m_overlayNameLength[i] = slen; |
|---|
| 1990 | if ( sei.m_overlayLabelPresentFlag[i] ) |
|---|
| 1991 | { |
|---|
| 1992 | sei.m_overlayElementName[i].resize( sei.m_numOverlayElementsMinus1[i]+1, NULL ); |
|---|
| 1993 | sei.m_overlayElementNameLength[i].resize( sei.m_numOverlayElementsMinus1[i]+1 ); |
|---|
| 1994 | for ( j=0 ; j<=sei.m_numOverlayElementsMinus1[i] ; j++) |
|---|
| 1995 | { |
|---|
| 1996 | READ_STRING( MAX_OVERLAY_STRING_BYTES, sval, slen, "overlay_element_name" ); |
|---|
| 1997 | sei.m_overlayElementName[i][j] = new UChar[slen]; |
|---|
| 1998 | memcpy(sei.m_overlayElementName[i][j], sval, slen); |
|---|
| 1999 | sei.m_overlayElementNameLength[i][j] = slen; |
|---|
| 2000 | } |
|---|
| 2001 | } |
|---|
| 2002 | } |
|---|
| 2003 | sei_read_flag( pDecodedMessageOutputStream, val, "overlay_info_persistence_flag" ); sei.m_overlayInfoPersistenceFlag = val; |
|---|
| 2004 | } |
|---|
| 2005 | } |
|---|
| 2006 | #endif |
|---|
| 2007 | |
|---|
| 2008 | #if P0138_USE_ALT_CPB_PARAMS_FLAG |
|---|
| 2009 | /** |
|---|
| 2010 | * Check if SEI message contains payload extension |
|---|
| 2011 | */ |
|---|
| 2012 | Bool SEIReader::xPayloadExtensionPresent() |
|---|
| 2013 | { |
|---|
| 2014 | Int payloadBitsRemaining = getBitstream()->getNumBitsLeft(); |
|---|
| 2015 | Bool payloadExtensionPresent = false; |
|---|
| 2016 | |
|---|
| 2017 | if (payloadBitsRemaining > 8) |
|---|
| 2018 | { |
|---|
| 2019 | payloadExtensionPresent = true; |
|---|
| 2020 | } |
|---|
| 2021 | else |
|---|
| 2022 | { |
|---|
| 2023 | Int finalBits = getBitstream()->peekBits(payloadBitsRemaining); |
|---|
| 2024 | while (payloadBitsRemaining && (finalBits & 1) == 0) |
|---|
| 2025 | { |
|---|
| 2026 | payloadBitsRemaining--; |
|---|
| 2027 | finalBits >>= 1; |
|---|
| 2028 | } |
|---|
| 2029 | payloadBitsRemaining--; |
|---|
| 2030 | if (payloadBitsRemaining > 0) |
|---|
| 2031 | { |
|---|
| 2032 | payloadExtensionPresent = true; |
|---|
| 2033 | } |
|---|
| 2034 | } |
|---|
| 2035 | |
|---|
| 2036 | return payloadExtensionPresent; |
|---|
| 2037 | } |
|---|
| 2038 | #endif |
|---|
| 2039 | |
|---|
| 2040 | #if Q0189_TMVP_CONSTRAINTS |
|---|
| 2041 | Void SEIReader::xParseSEITMVPConstraints (SEITMVPConstrains& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 2042 | { |
|---|
| 2043 | UInt uiCode; |
|---|
| 2044 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "prev_pics_not_used_flag" ); sei.prev_pics_not_used_flag = uiCode; |
|---|
| 2045 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "no_intra_layer_col_pic_flag" ); sei.no_intra_layer_col_pic_flag = uiCode; |
|---|
| 2046 | } |
|---|
| 2047 | #endif |
|---|
| 2048 | |
|---|
| 2049 | #if Q0247_FRAME_FIELD_INFO |
|---|
| 2050 | Void SEIReader::xParseSEIFrameFieldInfo (SEIFrameFieldInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
|---|
| 2051 | { |
|---|
| 2052 | UInt code; |
|---|
| 2053 | sei_read_code( pDecodedMessageOutputStream, 4, code, "ffinfo_pic_struct" ); sei.m_ffinfo_picStruct = code; |
|---|
| 2054 | sei_read_code( pDecodedMessageOutputStream, 2, code, "ffinfo_source_scan_type" ); sei.m_ffinfo_sourceScanType = code; |
|---|
| 2055 | sei_read_flag( pDecodedMessageOutputStream, code, "ffinfo_duplicate_flag" ); sei.m_ffinfo_duplicateFlag = ( code == 1 ? true : false ); |
|---|
| 2056 | } |
|---|
| 2057 | #endif |
|---|
| 2058 | |
|---|
| 2059 | |
|---|
| 2060 | #endif //SVC_EXTENSION |
|---|
| 2061 | |
|---|
| 2062 | //! \} |
|---|