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