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