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