[313] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
[595] | 6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
[313] | 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
| 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | /** |
---|
| 35 | \file SEIread.cpp |
---|
| 36 | \brief reading functionality for SEI messages |
---|
| 37 | */ |
---|
| 38 | |
---|
| 39 | #include "TLibCommon/CommonDef.h" |
---|
| 40 | #include "TLibCommon/TComBitStream.h" |
---|
| 41 | #include "TLibCommon/SEI.h" |
---|
| 42 | #include "TLibCommon/TComSlice.h" |
---|
| 43 | #include "SyntaxElementParser.h" |
---|
| 44 | #include "SEIread.h" |
---|
| 45 | |
---|
| 46 | //! \ingroup TLibDecoder |
---|
| 47 | //! \{ |
---|
| 48 | |
---|
| 49 | #if ENC_DEC_TRACE |
---|
| 50 | Void xTraceSEIHeader() |
---|
| 51 | { |
---|
| 52 | fprintf( g_hTrace, "=========== SEI message ===========\n"); |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | Void xTraceSEIMessageType(SEI::PayloadType payloadType) |
---|
| 56 | { |
---|
| 57 | switch (payloadType) |
---|
| 58 | { |
---|
| 59 | case SEI::DECODED_PICTURE_HASH: |
---|
| 60 | fprintf( g_hTrace, "=========== Decoded picture hash SEI message ===========\n"); |
---|
| 61 | break; |
---|
| 62 | case SEI::USER_DATA_UNREGISTERED: |
---|
| 63 | fprintf( g_hTrace, "=========== User Data Unregistered SEI message ===========\n"); |
---|
| 64 | break; |
---|
| 65 | case SEI::ACTIVE_PARAMETER_SETS: |
---|
| 66 | fprintf( g_hTrace, "=========== Active Parameter sets SEI message ===========\n"); |
---|
| 67 | break; |
---|
| 68 | case SEI::BUFFERING_PERIOD: |
---|
| 69 | fprintf( g_hTrace, "=========== Buffering period SEI message ===========\n"); |
---|
| 70 | break; |
---|
| 71 | case SEI::PICTURE_TIMING: |
---|
| 72 | fprintf( g_hTrace, "=========== Picture timing SEI message ===========\n"); |
---|
| 73 | break; |
---|
| 74 | case SEI::RECOVERY_POINT: |
---|
| 75 | fprintf( g_hTrace, "=========== Recovery point SEI message ===========\n"); |
---|
| 76 | break; |
---|
| 77 | case SEI::FRAME_PACKING: |
---|
| 78 | fprintf( g_hTrace, "=========== Frame Packing Arrangement SEI message ===========\n"); |
---|
| 79 | break; |
---|
| 80 | case SEI::DISPLAY_ORIENTATION: |
---|
| 81 | fprintf( g_hTrace, "=========== Display Orientation SEI message ===========\n"); |
---|
| 82 | break; |
---|
| 83 | case SEI::TEMPORAL_LEVEL0_INDEX: |
---|
| 84 | fprintf( g_hTrace, "=========== Temporal Level Zero Index SEI message ===========\n"); |
---|
| 85 | break; |
---|
| 86 | case SEI::REGION_REFRESH_INFO: |
---|
| 87 | fprintf( g_hTrace, "=========== Gradual Decoding Refresh Information SEI message ===========\n"); |
---|
| 88 | break; |
---|
| 89 | case SEI::DECODING_UNIT_INFO: |
---|
| 90 | fprintf( g_hTrace, "=========== Decoding Unit Information SEI message ===========\n"); |
---|
| 91 | break; |
---|
| 92 | case SEI::TONE_MAPPING_INFO: |
---|
| 93 | fprintf( g_hTrace, "===========Tone Mapping Info SEI message ===========\n"); |
---|
| 94 | break; |
---|
[713] | 95 | #if Q0074_SEI_COLOR_MAPPING |
---|
| 96 | case SEI::COLOR_MAPPING_INFO: |
---|
| 97 | fprintf( g_hTrace, "===========Color Mapping Info SEI message ===========\n"); |
---|
| 98 | break; |
---|
| 99 | #endif |
---|
[595] | 100 | case SEI::SOP_DESCRIPTION: |
---|
| 101 | fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n"); |
---|
| 102 | break; |
---|
| 103 | case SEI::SCALABLE_NESTING: |
---|
| 104 | fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n"); |
---|
| 105 | break; |
---|
| 106 | #if SVC_EXTENSION |
---|
[588] | 107 | #if LAYERS_NOT_PRESENT_SEI |
---|
| 108 | case SEI::LAYERS_NOT_PRESENT: |
---|
[313] | 109 | fprintf( g_hTrace, "=========== Layers Present SEI message ===========\n"); |
---|
| 110 | break; |
---|
| 111 | #endif |
---|
[442] | 112 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
| 113 | case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: |
---|
| 114 | fprintf( g_hTrace, "=========== Inter Layer Constrained Tile Sets SEI message ===========\n"); |
---|
| 115 | break; |
---|
| 116 | #endif |
---|
[588] | 117 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
[644] | 118 | case SEI::SUB_BITSTREAM_PROPERTY: |
---|
| 119 | fprintf( g_hTrace, "=========== Sub-bitstream property SEI message ===========\n"); |
---|
| 120 | break; |
---|
[588] | 121 | #endif |
---|
[644] | 122 | #if O0164_MULTI_LAYER_HRD |
---|
| 123 | case SEI::BSP_NESTING: |
---|
| 124 | fprintf( g_hTrace, "=========== Bitstream parition nesting SEI message ===========\n"); |
---|
| 125 | break; |
---|
| 126 | case SEI::BSP_INITIAL_ARRIVAL_TIME: |
---|
| 127 | fprintf( g_hTrace, "=========== Bitstream parition initial arrival time SEI message ===========\n"); |
---|
| 128 | break; |
---|
| 129 | case SEI::BSP_HRD: |
---|
| 130 | fprintf( g_hTrace, "=========== Bitstream parition HRD parameters SEI message ===========\n"); |
---|
| 131 | break; |
---|
| 132 | #endif |
---|
[595] | 133 | #endif //SVC_EXTENSION |
---|
[313] | 134 | default: |
---|
| 135 | fprintf( g_hTrace, "=========== Unknown SEI message ===========\n"); |
---|
| 136 | break; |
---|
| 137 | } |
---|
| 138 | } |
---|
| 139 | #endif |
---|
| 140 | |
---|
| 141 | /** |
---|
| 142 | * unmarshal a single SEI message from bitstream bs |
---|
| 143 | */ |
---|
[588] | 144 | #if LAYERS_NOT_PRESENT_SEI |
---|
[313] | 145 | void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps) |
---|
| 146 | #else |
---|
| 147 | void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps) |
---|
| 148 | #endif |
---|
| 149 | { |
---|
| 150 | setBitstream(bs); |
---|
| 151 | |
---|
| 152 | assert(!m_pcBitstream->getNumBitsUntilByteAligned()); |
---|
| 153 | do |
---|
| 154 | { |
---|
[588] | 155 | #if LAYERS_NOT_PRESENT_SEI |
---|
[313] | 156 | xReadSEImessage(seis, nalUnitType, vps, sps); |
---|
| 157 | #else |
---|
| 158 | xReadSEImessage(seis, nalUnitType, sps); |
---|
| 159 | #endif |
---|
| 160 | /* SEI messages are an integer number of bytes, something has failed |
---|
| 161 | * in the parsing if bitstream not byte-aligned */ |
---|
| 162 | assert(!m_pcBitstream->getNumBitsUntilByteAligned()); |
---|
| 163 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
---|
| 164 | |
---|
| 165 | UInt rbspTrailingBits; |
---|
| 166 | READ_CODE(8, rbspTrailingBits, "rbsp_trailing_bits"); |
---|
| 167 | assert(rbspTrailingBits == 0x80); |
---|
| 168 | } |
---|
| 169 | |
---|
[644] | 170 | #if O0164_MULTI_LAYER_HRD |
---|
[588] | 171 | #if LAYERS_NOT_PRESENT_SEI |
---|
[644] | 172 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, const SEIScalableNesting *nestingSei, const SEIBspNesting *bspNestingSei) |
---|
| 173 | #else |
---|
| 174 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps, const SEIScalableNesting *nestingSei) |
---|
| 175 | #endif |
---|
| 176 | #else |
---|
| 177 | #if LAYERS_NOT_PRESENT_SEI |
---|
[313] | 178 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps) |
---|
| 179 | #else |
---|
| 180 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps) |
---|
| 181 | #endif |
---|
[644] | 182 | #endif |
---|
[313] | 183 | { |
---|
| 184 | #if ENC_DEC_TRACE |
---|
| 185 | xTraceSEIHeader(); |
---|
| 186 | #endif |
---|
| 187 | Int payloadType = 0; |
---|
| 188 | UInt val = 0; |
---|
| 189 | |
---|
| 190 | do |
---|
| 191 | { |
---|
| 192 | READ_CODE (8, val, "payload_type"); |
---|
| 193 | payloadType += val; |
---|
| 194 | } while (val==0xFF); |
---|
| 195 | |
---|
| 196 | UInt payloadSize = 0; |
---|
| 197 | do |
---|
| 198 | { |
---|
| 199 | READ_CODE (8, val, "payload_size"); |
---|
| 200 | payloadSize += val; |
---|
| 201 | } while (val==0xFF); |
---|
| 202 | |
---|
| 203 | #if ENC_DEC_TRACE |
---|
| 204 | xTraceSEIMessageType((SEI::PayloadType)payloadType); |
---|
| 205 | #endif |
---|
| 206 | |
---|
| 207 | /* extract the payload for this single SEI message. |
---|
| 208 | * This allows greater safety in erroneous parsing of an SEI message |
---|
| 209 | * from affecting subsequent messages. |
---|
| 210 | * After parsing the payload, bs needs to be restored as the primary |
---|
| 211 | * bitstream. |
---|
| 212 | */ |
---|
| 213 | TComInputBitstream *bs = getBitstream(); |
---|
| 214 | setBitstream(bs->extractSubstream(payloadSize * 8)); |
---|
| 215 | |
---|
| 216 | SEI *sei = NULL; |
---|
| 217 | |
---|
| 218 | if(nalUnitType == NAL_UNIT_PREFIX_SEI) |
---|
| 219 | { |
---|
| 220 | switch (payloadType) |
---|
| 221 | { |
---|
| 222 | case SEI::USER_DATA_UNREGISTERED: |
---|
| 223 | sei = new SEIuserDataUnregistered; |
---|
| 224 | xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize); |
---|
| 225 | break; |
---|
| 226 | case SEI::ACTIVE_PARAMETER_SETS: |
---|
| 227 | sei = new SEIActiveParameterSets; |
---|
| 228 | xParseSEIActiveParameterSets((SEIActiveParameterSets&) *sei, payloadSize); |
---|
| 229 | break; |
---|
| 230 | case SEI::DECODING_UNIT_INFO: |
---|
| 231 | if (!sps) |
---|
| 232 | { |
---|
| 233 | printf ("Warning: Found Decoding unit SEI message, but no active SPS is available. Ignoring."); |
---|
| 234 | } |
---|
| 235 | else |
---|
| 236 | { |
---|
| 237 | sei = new SEIDecodingUnitInfo; |
---|
| 238 | xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps); |
---|
| 239 | } |
---|
| 240 | break; |
---|
| 241 | case SEI::BUFFERING_PERIOD: |
---|
| 242 | if (!sps) |
---|
| 243 | { |
---|
| 244 | printf ("Warning: Found Buffering period SEI message, but no active SPS is available. Ignoring."); |
---|
| 245 | } |
---|
| 246 | else |
---|
| 247 | { |
---|
| 248 | sei = new SEIBufferingPeriod; |
---|
| 249 | xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps); |
---|
| 250 | } |
---|
| 251 | break; |
---|
| 252 | case SEI::PICTURE_TIMING: |
---|
| 253 | if (!sps) |
---|
| 254 | { |
---|
| 255 | printf ("Warning: Found Picture timing SEI message, but no active SPS is available. Ignoring."); |
---|
| 256 | } |
---|
| 257 | else |
---|
| 258 | { |
---|
| 259 | sei = new SEIPictureTiming; |
---|
| 260 | xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps); |
---|
| 261 | } |
---|
| 262 | break; |
---|
| 263 | case SEI::RECOVERY_POINT: |
---|
| 264 | sei = new SEIRecoveryPoint; |
---|
| 265 | xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize); |
---|
| 266 | break; |
---|
| 267 | case SEI::FRAME_PACKING: |
---|
| 268 | sei = new SEIFramePacking; |
---|
| 269 | xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize); |
---|
| 270 | break; |
---|
| 271 | case SEI::DISPLAY_ORIENTATION: |
---|
| 272 | sei = new SEIDisplayOrientation; |
---|
| 273 | xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize); |
---|
| 274 | break; |
---|
| 275 | case SEI::TEMPORAL_LEVEL0_INDEX: |
---|
| 276 | sei = new SEITemporalLevel0Index; |
---|
| 277 | xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize); |
---|
| 278 | break; |
---|
| 279 | case SEI::REGION_REFRESH_INFO: |
---|
| 280 | sei = new SEIGradualDecodingRefreshInfo; |
---|
| 281 | xParseSEIGradualDecodingRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize); |
---|
| 282 | break; |
---|
| 283 | case SEI::TONE_MAPPING_INFO: |
---|
| 284 | sei = new SEIToneMappingInfo; |
---|
| 285 | xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize); |
---|
| 286 | break; |
---|
[713] | 287 | #if Q0074_SEI_COLOR_MAPPING |
---|
| 288 | case SEI::COLOR_MAPPING_INFO: |
---|
| 289 | sei = new SEIColorMappingInfo; |
---|
| 290 | xParseSEIColorMappingInfo((SEIColorMappingInfo&) *sei, payloadSize); |
---|
| 291 | break; |
---|
| 292 | #endif |
---|
[595] | 293 | case SEI::SOP_DESCRIPTION: |
---|
| 294 | sei = new SEISOPDescription; |
---|
| 295 | xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize); |
---|
| 296 | break; |
---|
| 297 | case SEI::SCALABLE_NESTING: |
---|
| 298 | sei = new SEIScalableNesting; |
---|
[588] | 299 | #if LAYERS_NOT_PRESENT_SEI |
---|
[595] | 300 | xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, vps, sps); |
---|
| 301 | #else |
---|
| 302 | xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps); |
---|
| 303 | #endif |
---|
[644] | 304 | break; |
---|
[595] | 305 | #if SVC_EXTENSION |
---|
| 306 | #if LAYERS_NOT_PRESENT_SEI |
---|
[588] | 307 | case SEI::LAYERS_NOT_PRESENT: |
---|
[313] | 308 | if (!vps) |
---|
| 309 | { |
---|
[588] | 310 | printf ("Warning: Found Layers not present SEI message, but no active VPS is available. Ignoring."); |
---|
[313] | 311 | } |
---|
| 312 | else |
---|
| 313 | { |
---|
[588] | 314 | sei = new SEILayersNotPresent; |
---|
| 315 | xParseSEILayersNotPresent((SEILayersNotPresent&) *sei, payloadSize, vps); |
---|
[313] | 316 | } |
---|
| 317 | break; |
---|
| 318 | #endif |
---|
[442] | 319 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
| 320 | case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: |
---|
| 321 | sei = new SEIInterLayerConstrainedTileSets; |
---|
| 322 | xParseSEIInterLayerConstrainedTileSets((SEIInterLayerConstrainedTileSets&) *sei, payloadSize); |
---|
| 323 | break; |
---|
| 324 | #endif |
---|
[588] | 325 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
| 326 | case SEI::SUB_BITSTREAM_PROPERTY: |
---|
| 327 | sei = new SEISubBitstreamProperty; |
---|
| 328 | xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei); |
---|
| 329 | break; |
---|
| 330 | #endif |
---|
[644] | 331 | #if O0164_MULTI_LAYER_HRD |
---|
| 332 | case SEI::BSP_NESTING: |
---|
| 333 | sei = new SEIBspNesting; |
---|
| 334 | #if LAYERS_NOT_PRESENT_SEI |
---|
| 335 | xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, vps, sps, *nestingSei); |
---|
| 336 | #else |
---|
| 337 | xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, sps, *nestingSei); |
---|
| 338 | #endif |
---|
| 339 | break; |
---|
| 340 | case SEI::BSP_INITIAL_ARRIVAL_TIME: |
---|
| 341 | sei = new SEIBspInitialArrivalTime; |
---|
| 342 | xParseSEIBspInitialArrivalTime((SEIBspInitialArrivalTime&) *sei, vps, sps, *nestingSei, *bspNestingSei); |
---|
| 343 | break; |
---|
| 344 | case SEI::BSP_HRD: |
---|
| 345 | sei = new SEIBspHrd; |
---|
| 346 | xParseSEIBspHrd((SEIBspHrd&) *sei, sps, *nestingSei); |
---|
| 347 | break; |
---|
| 348 | #endif |
---|
[595] | 349 | #endif //SVC_EXTENSION |
---|
[313] | 350 | break; |
---|
| 351 | default: |
---|
| 352 | for (UInt i = 0; i < payloadSize; i++) |
---|
| 353 | { |
---|
| 354 | UInt seiByte; |
---|
| 355 | READ_CODE (8, seiByte, "unknown prefix SEI payload byte"); |
---|
| 356 | } |
---|
| 357 | printf ("Unknown prefix SEI message (payloadType = %d) was found!\n", payloadType); |
---|
| 358 | } |
---|
| 359 | } |
---|
| 360 | else |
---|
| 361 | { |
---|
| 362 | switch (payloadType) |
---|
| 363 | { |
---|
| 364 | case SEI::USER_DATA_UNREGISTERED: |
---|
| 365 | sei = new SEIuserDataUnregistered; |
---|
| 366 | xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize); |
---|
| 367 | break; |
---|
| 368 | case SEI::DECODED_PICTURE_HASH: |
---|
| 369 | sei = new SEIDecodedPictureHash; |
---|
| 370 | xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize); |
---|
| 371 | break; |
---|
| 372 | default: |
---|
| 373 | for (UInt i = 0; i < payloadSize; i++) |
---|
| 374 | { |
---|
| 375 | UInt seiByte; |
---|
| 376 | READ_CODE (8, seiByte, "unknown suffix SEI payload byte"); |
---|
| 377 | } |
---|
| 378 | printf ("Unknown suffix SEI message (payloadType = %d) was found!\n", payloadType); |
---|
| 379 | } |
---|
| 380 | } |
---|
| 381 | if (sei != NULL) |
---|
| 382 | { |
---|
| 383 | seis.push_back(sei); |
---|
| 384 | } |
---|
| 385 | |
---|
| 386 | /* By definition the underlying bitstream terminates in a byte-aligned manner. |
---|
| 387 | * 1. Extract all bar the last MIN(bitsremaining,nine) bits as reserved_payload_extension_data |
---|
| 388 | * 2. Examine the final 8 bits to determine the payload_bit_equal_to_one marker |
---|
| 389 | * 3. Extract the remainingreserved_payload_extension_data bits. |
---|
| 390 | * |
---|
| 391 | * If there are fewer than 9 bits available, extract them. |
---|
| 392 | */ |
---|
| 393 | Int payloadBitsRemaining = getBitstream()->getNumBitsLeft(); |
---|
| 394 | if (payloadBitsRemaining) /* more_data_in_payload() */ |
---|
| 395 | { |
---|
| 396 | for (; payloadBitsRemaining > 9; payloadBitsRemaining--) |
---|
| 397 | { |
---|
| 398 | UInt reservedPayloadExtensionData; |
---|
| 399 | READ_CODE (1, reservedPayloadExtensionData, "reserved_payload_extension_data"); |
---|
| 400 | } |
---|
| 401 | |
---|
| 402 | /* 2 */ |
---|
| 403 | Int finalBits = getBitstream()->peekBits(payloadBitsRemaining); |
---|
| 404 | Int finalPayloadBits = 0; |
---|
| 405 | for (Int mask = 0xff; finalBits & (mask >> finalPayloadBits); finalPayloadBits++) |
---|
| 406 | { |
---|
| 407 | continue; |
---|
| 408 | } |
---|
| 409 | |
---|
| 410 | /* 3 */ |
---|
| 411 | for (; payloadBitsRemaining > 9 - finalPayloadBits; payloadBitsRemaining--) |
---|
| 412 | { |
---|
| 413 | UInt reservedPayloadExtensionData; |
---|
| 414 | READ_FLAG (reservedPayloadExtensionData, "reserved_payload_extension_data"); |
---|
| 415 | } |
---|
| 416 | |
---|
| 417 | UInt dummy; |
---|
| 418 | READ_FLAG (dummy, "payload_bit_equal_to_one"); payloadBitsRemaining--; |
---|
| 419 | while (payloadBitsRemaining) |
---|
| 420 | { |
---|
| 421 | READ_FLAG (dummy, "payload_bit_equal_to_zero"); payloadBitsRemaining--; |
---|
| 422 | } |
---|
| 423 | } |
---|
| 424 | |
---|
| 425 | /* restore primary bitstream for sei_message */ |
---|
[442] | 426 | getBitstream()->deleteFifo(); |
---|
[313] | 427 | delete getBitstream(); |
---|
| 428 | setBitstream(bs); |
---|
| 429 | } |
---|
| 430 | |
---|
[644] | 431 | #if P0138_USE_ALT_CPB_PARAMS_FLAG |
---|
[313] | 432 | /** |
---|
[644] | 433 | * Check if SEI message contains payload extension |
---|
| 434 | */ |
---|
| 435 | Bool SEIReader::xPayloadExtensionPresent() |
---|
| 436 | { |
---|
| 437 | Int payloadBitsRemaining = getBitstream()->getNumBitsLeft(); |
---|
| 438 | Bool payloadExtensionPresent = false; |
---|
| 439 | |
---|
| 440 | if (payloadBitsRemaining > 8) |
---|
| 441 | { |
---|
| 442 | payloadExtensionPresent = true; |
---|
| 443 | } |
---|
| 444 | else |
---|
| 445 | { |
---|
| 446 | Int finalBits = getBitstream()->peekBits(payloadBitsRemaining); |
---|
| 447 | while (payloadBitsRemaining && (finalBits & 1) == 0) |
---|
| 448 | { |
---|
| 449 | payloadBitsRemaining--; |
---|
| 450 | finalBits >>= 1; |
---|
| 451 | } |
---|
| 452 | payloadBitsRemaining--; |
---|
| 453 | if (payloadBitsRemaining > 0) |
---|
| 454 | { |
---|
| 455 | payloadExtensionPresent = true; |
---|
| 456 | } |
---|
| 457 | } |
---|
| 458 | |
---|
| 459 | return payloadExtensionPresent; |
---|
| 460 | } |
---|
| 461 | #endif |
---|
| 462 | |
---|
| 463 | /** |
---|
[313] | 464 | * parse bitstream bs and unpack a user_data_unregistered SEI message |
---|
| 465 | * of payloasSize bytes into sei. |
---|
| 466 | */ |
---|
| 467 | Void SEIReader::xParseSEIuserDataUnregistered(SEIuserDataUnregistered &sei, UInt payloadSize) |
---|
| 468 | { |
---|
| 469 | assert(payloadSize >= 16); |
---|
| 470 | UInt val; |
---|
| 471 | |
---|
| 472 | for (UInt i = 0; i < 16; i++) |
---|
| 473 | { |
---|
| 474 | READ_CODE (8, val, "uuid_iso_iec_11578"); |
---|
| 475 | sei.uuid_iso_iec_11578[i] = val; |
---|
| 476 | } |
---|
| 477 | |
---|
| 478 | sei.userDataLength = payloadSize - 16; |
---|
| 479 | if (!sei.userDataLength) |
---|
| 480 | { |
---|
| 481 | sei.userData = 0; |
---|
| 482 | return; |
---|
| 483 | } |
---|
| 484 | |
---|
| 485 | sei.userData = new UChar[sei.userDataLength]; |
---|
| 486 | for (UInt i = 0; i < sei.userDataLength; i++) |
---|
| 487 | { |
---|
| 488 | READ_CODE (8, val, "user_data" ); |
---|
| 489 | sei.userData[i] = val; |
---|
| 490 | } |
---|
| 491 | } |
---|
| 492 | |
---|
| 493 | /** |
---|
| 494 | * parse bitstream bs and unpack a decoded picture hash SEI message |
---|
| 495 | * of payloadSize bytes into sei. |
---|
| 496 | */ |
---|
| 497 | Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt /*payloadSize*/) |
---|
| 498 | { |
---|
| 499 | UInt val; |
---|
| 500 | READ_CODE (8, val, "hash_type"); |
---|
| 501 | sei.method = static_cast<SEIDecodedPictureHash::Method>(val); |
---|
| 502 | for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++) |
---|
| 503 | { |
---|
| 504 | if(SEIDecodedPictureHash::MD5 == sei.method) |
---|
| 505 | { |
---|
| 506 | for (UInt i = 0; i < 16; i++) |
---|
| 507 | { |
---|
| 508 | READ_CODE(8, val, "picture_md5"); |
---|
| 509 | sei.digest[yuvIdx][i] = val; |
---|
| 510 | } |
---|
| 511 | } |
---|
| 512 | else if(SEIDecodedPictureHash::CRC == sei.method) |
---|
| 513 | { |
---|
| 514 | READ_CODE(16, val, "picture_crc"); |
---|
| 515 | sei.digest[yuvIdx][0] = val >> 8 & 0xFF; |
---|
| 516 | sei.digest[yuvIdx][1] = val & 0xFF; |
---|
| 517 | } |
---|
| 518 | else if(SEIDecodedPictureHash::CHECKSUM == sei.method) |
---|
| 519 | { |
---|
| 520 | READ_CODE(32, val, "picture_checksum"); |
---|
| 521 | sei.digest[yuvIdx][0] = (val>>24) & 0xff; |
---|
| 522 | sei.digest[yuvIdx][1] = (val>>16) & 0xff; |
---|
| 523 | sei.digest[yuvIdx][2] = (val>>8) & 0xff; |
---|
| 524 | sei.digest[yuvIdx][3] = val & 0xff; |
---|
| 525 | } |
---|
| 526 | } |
---|
| 527 | } |
---|
| 528 | Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt /*payloadSize*/) |
---|
| 529 | { |
---|
| 530 | UInt val; |
---|
[713] | 531 | READ_CODE(4, val, "active_video_parameter_set_id"); sei.activeVPSId = val; |
---|
| 532 | READ_FLAG( val, "self_contained_cvs_flag"); sei.m_selfContainedCvsFlag = val ? true : false; |
---|
| 533 | READ_FLAG( val, "no_parameter_set_update_flag"); sei.m_noParameterSetUpdateFlag = val ? true : false; |
---|
[313] | 534 | READ_UVLC( val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val; |
---|
| 535 | |
---|
[713] | 536 | sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1); |
---|
[313] | 537 | for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++) |
---|
| 538 | { |
---|
[713] | 539 | READ_UVLC(val, "active_seq_parameter_set_id"); sei.activeSeqParameterSetId[i] = val; |
---|
[313] | 540 | } |
---|
| 541 | |
---|
[713] | 542 | xParseByteAlign(); |
---|
[313] | 543 | } |
---|
| 544 | |
---|
| 545 | Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt /*payloadSize*/, TComSPS *sps) |
---|
| 546 | { |
---|
| 547 | UInt val; |
---|
| 548 | READ_UVLC(val, "decoding_unit_idx"); |
---|
| 549 | sei.m_decodingUnitIdx = val; |
---|
| 550 | |
---|
| 551 | TComVUI *vui = sps->getVuiParameters(); |
---|
| 552 | if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag()) |
---|
| 553 | { |
---|
| 554 | READ_CODE( ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay"); |
---|
| 555 | sei.m_duSptCpbRemovalDelay = val; |
---|
| 556 | } |
---|
| 557 | else |
---|
| 558 | { |
---|
| 559 | sei.m_duSptCpbRemovalDelay = 0; |
---|
| 560 | } |
---|
| 561 | READ_FLAG( val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = val ? true : false; |
---|
| 562 | if(sei.m_dpbOutputDuDelayPresentFlag) |
---|
| 563 | { |
---|
| 564 | READ_CODE(vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay"); |
---|
| 565 | sei.m_picSptDpbOutputDuDelay = val; |
---|
| 566 | } |
---|
| 567 | xParseByteAlign(); |
---|
| 568 | } |
---|
| 569 | |
---|
| 570 | Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt /*payloadSize*/, TComSPS *sps) |
---|
| 571 | { |
---|
| 572 | Int i, nalOrVcl; |
---|
| 573 | UInt code; |
---|
| 574 | |
---|
| 575 | TComVUI *pVUI = sps->getVuiParameters(); |
---|
| 576 | TComHRD *pHRD = pVUI->getHrdParameters(); |
---|
| 577 | |
---|
| 578 | READ_UVLC( code, "bp_seq_parameter_set_id" ); sei.m_bpSeqParameterSetId = code; |
---|
| 579 | if( !pHRD->getSubPicCpbParamsPresentFlag() ) |
---|
| 580 | { |
---|
[595] | 581 | READ_FLAG( code, "irap_cpb_params_present_flag" ); sei.m_rapCpbParamsPresentFlag = code; |
---|
[313] | 582 | } |
---|
[595] | 583 | if( sei.m_rapCpbParamsPresentFlag ) |
---|
| 584 | { |
---|
| 585 | READ_CODE( pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" ); sei.m_cpbDelayOffset = code; |
---|
| 586 | READ_CODE( pHRD->getDpbOutputDelayLengthMinus1() + 1, code, "dpb_delay_offset" ); sei.m_dpbDelayOffset = code; |
---|
| 587 | } |
---|
[313] | 588 | //read splicing flag and cpb_removal_delay_delta |
---|
| 589 | READ_FLAG( code, "concatenation_flag"); |
---|
| 590 | sei.m_concatenationFlag = code; |
---|
| 591 | READ_CODE( ( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" ); |
---|
| 592 | sei.m_auCpbRemovalDelayDelta = code + 1; |
---|
| 593 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
| 594 | { |
---|
| 595 | if( ( ( nalOrVcl == 0 ) && ( pHRD->getNalHrdParametersPresentFlag() ) ) || |
---|
| 596 | ( ( nalOrVcl == 1 ) && ( pHRD->getVclHrdParametersPresentFlag() ) ) ) |
---|
| 597 | { |
---|
| 598 | for( i = 0; i < ( pHRD->getCpbCntMinus1( 0 ) + 1 ); i ++ ) |
---|
| 599 | { |
---|
| 600 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay" ); |
---|
| 601 | sei.m_initialCpbRemovalDelay[i][nalOrVcl] = code; |
---|
| 602 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay_offset" ); |
---|
| 603 | sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl] = code; |
---|
| 604 | if( pHRD->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag ) |
---|
| 605 | { |
---|
| 606 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay" ); |
---|
| 607 | sei.m_initialAltCpbRemovalDelay[i][nalOrVcl] = code; |
---|
| 608 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay_offset" ); |
---|
| 609 | sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl] = code; |
---|
| 610 | } |
---|
| 611 | } |
---|
| 612 | } |
---|
| 613 | } |
---|
[644] | 614 | |
---|
| 615 | #if P0138_USE_ALT_CPB_PARAMS_FLAG |
---|
| 616 | sei.m_useAltCpbParamsFlag = false; |
---|
| 617 | sei.m_useAltCpbParamsFlagPresent = false; |
---|
| 618 | if (xPayloadExtensionPresent()) |
---|
| 619 | { |
---|
| 620 | READ_FLAG (code, "use_alt_cpb_params_flag"); |
---|
| 621 | sei.m_useAltCpbParamsFlag = code; |
---|
| 622 | sei.m_useAltCpbParamsFlagPresent = true; |
---|
| 623 | } |
---|
| 624 | #endif |
---|
| 625 | |
---|
[313] | 626 | xParseByteAlign(); |
---|
| 627 | } |
---|
| 628 | Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt /*payloadSize*/, TComSPS *sps) |
---|
| 629 | { |
---|
| 630 | Int i; |
---|
| 631 | UInt code; |
---|
| 632 | |
---|
| 633 | TComVUI *vui = sps->getVuiParameters(); |
---|
| 634 | TComHRD *hrd = vui->getHrdParameters(); |
---|
| 635 | |
---|
| 636 | if( vui->getFrameFieldInfoPresentFlag() ) |
---|
| 637 | { |
---|
| 638 | READ_CODE( 4, code, "pic_struct" ); sei.m_picStruct = code; |
---|
| 639 | READ_CODE( 2, code, "source_scan_type" ); sei.m_sourceScanType = code; |
---|
| 640 | READ_FLAG( code, "duplicate_flag" ); sei.m_duplicateFlag = ( code == 1 ? true : false ); |
---|
| 641 | } |
---|
| 642 | |
---|
| 643 | if( hrd->getCpbDpbDelaysPresentFlag()) |
---|
| 644 | { |
---|
| 645 | READ_CODE( ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" ); |
---|
| 646 | sei.m_auCpbRemovalDelay = code + 1; |
---|
| 647 | READ_CODE( ( hrd->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" ); |
---|
| 648 | sei.m_picDpbOutputDelay = code; |
---|
| 649 | |
---|
| 650 | if(hrd->getSubPicCpbParamsPresentFlag()) |
---|
| 651 | { |
---|
| 652 | READ_CODE(hrd->getDpbOutputDelayDuLengthMinus1()+1, code, "pic_dpb_output_du_delay" ); |
---|
| 653 | sei.m_picDpbOutputDuDelay = code; |
---|
| 654 | } |
---|
| 655 | if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() ) |
---|
| 656 | { |
---|
| 657 | READ_UVLC( code, "num_decoding_units_minus1"); |
---|
| 658 | sei.m_numDecodingUnitsMinus1 = code; |
---|
| 659 | READ_FLAG( code, "du_common_cpb_removal_delay_flag" ); |
---|
| 660 | sei.m_duCommonCpbRemovalDelayFlag = code; |
---|
| 661 | if( sei.m_duCommonCpbRemovalDelayFlag ) |
---|
| 662 | { |
---|
| 663 | READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_minus1" ); |
---|
| 664 | sei.m_duCommonCpbRemovalDelayMinus1 = code; |
---|
| 665 | } |
---|
| 666 | if( sei.m_numNalusInDuMinus1 != NULL ) |
---|
| 667 | { |
---|
| 668 | delete sei.m_numNalusInDuMinus1; |
---|
| 669 | } |
---|
| 670 | sei.m_numNalusInDuMinus1 = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ]; |
---|
| 671 | if( sei.m_duCpbRemovalDelayMinus1 != NULL ) |
---|
| 672 | { |
---|
| 673 | delete sei.m_duCpbRemovalDelayMinus1; |
---|
| 674 | } |
---|
| 675 | sei.m_duCpbRemovalDelayMinus1 = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ]; |
---|
| 676 | |
---|
| 677 | for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ ) |
---|
| 678 | { |
---|
| 679 | READ_UVLC( code, "num_nalus_in_du_minus1"); |
---|
| 680 | sei.m_numNalusInDuMinus1[ i ] = code; |
---|
| 681 | if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) ) |
---|
| 682 | { |
---|
| 683 | READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1" ); |
---|
| 684 | sei.m_duCpbRemovalDelayMinus1[ i ] = code; |
---|
| 685 | } |
---|
| 686 | } |
---|
| 687 | } |
---|
| 688 | } |
---|
| 689 | xParseByteAlign(); |
---|
| 690 | } |
---|
| 691 | Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt /*payloadSize*/) |
---|
| 692 | { |
---|
| 693 | Int iCode; |
---|
| 694 | UInt uiCode; |
---|
| 695 | READ_SVLC( iCode, "recovery_poc_cnt" ); sei.m_recoveryPocCnt = iCode; |
---|
| 696 | READ_FLAG( uiCode, "exact_matching_flag" ); sei.m_exactMatchingFlag = uiCode; |
---|
| 697 | READ_FLAG( uiCode, "broken_link_flag" ); sei.m_brokenLinkFlag = uiCode; |
---|
| 698 | xParseByteAlign(); |
---|
| 699 | } |
---|
| 700 | Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt /*payloadSize*/) |
---|
| 701 | { |
---|
| 702 | UInt val; |
---|
| 703 | READ_UVLC( val, "frame_packing_arrangement_id" ); sei.m_arrangementId = val; |
---|
| 704 | READ_FLAG( val, "frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; |
---|
| 705 | |
---|
| 706 | if ( !sei.m_arrangementCancelFlag ) |
---|
| 707 | { |
---|
| 708 | READ_CODE( 7, val, "frame_packing_arrangement_type" ); sei.m_arrangementType = val; |
---|
| 709 | assert((sei.m_arrangementType > 2) && (sei.m_arrangementType < 6) ); |
---|
| 710 | READ_FLAG( val, "quincunx_sampling_flag" ); sei.m_quincunxSamplingFlag = val; |
---|
| 711 | |
---|
| 712 | READ_CODE( 6, val, "content_interpretation_type" ); sei.m_contentInterpretationType = val; |
---|
| 713 | READ_FLAG( val, "spatial_flipping_flag" ); sei.m_spatialFlippingFlag = val; |
---|
| 714 | READ_FLAG( val, "frame0_flipped_flag" ); sei.m_frame0FlippedFlag = val; |
---|
| 715 | READ_FLAG( val, "field_views_flag" ); sei.m_fieldViewsFlag = val; |
---|
| 716 | READ_FLAG( val, "current_frame_is_frame0_flag" ); sei.m_currentFrameIsFrame0Flag = val; |
---|
| 717 | READ_FLAG( val, "frame0_self_contained_flag" ); sei.m_frame0SelfContainedFlag = val; |
---|
| 718 | READ_FLAG( val, "frame1_self_contained_flag" ); sei.m_frame1SelfContainedFlag = val; |
---|
| 719 | |
---|
| 720 | if ( sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5) |
---|
| 721 | { |
---|
| 722 | READ_CODE( 4, val, "frame0_grid_position_x" ); sei.m_frame0GridPositionX = val; |
---|
| 723 | READ_CODE( 4, val, "frame0_grid_position_y" ); sei.m_frame0GridPositionY = val; |
---|
| 724 | READ_CODE( 4, val, "frame1_grid_position_x" ); sei.m_frame1GridPositionX = val; |
---|
| 725 | READ_CODE( 4, val, "frame1_grid_position_y" ); sei.m_frame1GridPositionY = val; |
---|
| 726 | } |
---|
| 727 | |
---|
| 728 | READ_CODE( 8, val, "frame_packing_arrangement_reserved_byte" ); sei.m_arrangementReservedByte = val; |
---|
| 729 | READ_FLAG( val, "frame_packing_arrangement_persistence_flag" ); sei.m_arrangementPersistenceFlag = val ? true : false; |
---|
| 730 | } |
---|
| 731 | READ_FLAG( val, "upsampled_aspect_ratio" ); sei.m_upsampledAspectRatio = val; |
---|
| 732 | |
---|
| 733 | xParseByteAlign(); |
---|
| 734 | } |
---|
| 735 | |
---|
| 736 | Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt /*payloadSize*/) |
---|
| 737 | { |
---|
| 738 | UInt val; |
---|
| 739 | READ_FLAG( val, "display_orientation_cancel_flag" ); sei.cancelFlag = val; |
---|
| 740 | if( !sei.cancelFlag ) |
---|
| 741 | { |
---|
| 742 | READ_FLAG( val, "hor_flip" ); sei.horFlip = val; |
---|
| 743 | READ_FLAG( val, "ver_flip" ); sei.verFlip = val; |
---|
| 744 | READ_CODE( 16, val, "anticlockwise_rotation" ); sei.anticlockwiseRotation = val; |
---|
| 745 | READ_FLAG( val, "display_orientation_persistence_flag" ); sei.persistenceFlag = val; |
---|
| 746 | } |
---|
| 747 | xParseByteAlign(); |
---|
| 748 | } |
---|
| 749 | |
---|
| 750 | Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt /*payloadSize*/) |
---|
| 751 | { |
---|
| 752 | UInt val; |
---|
| 753 | READ_CODE ( 8, val, "tl0_idx" ); sei.tl0Idx = val; |
---|
| 754 | READ_CODE ( 8, val, "rap_idx" ); sei.rapIdx = val; |
---|
| 755 | xParseByteAlign(); |
---|
| 756 | } |
---|
| 757 | |
---|
| 758 | Void SEIReader::xParseSEIGradualDecodingRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt /*payloadSize*/) |
---|
| 759 | { |
---|
| 760 | UInt val; |
---|
| 761 | READ_FLAG( val, "gdr_foreground_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0; |
---|
| 762 | xParseByteAlign(); |
---|
| 763 | } |
---|
| 764 | |
---|
| 765 | Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt /*payloadSize*/) |
---|
| 766 | { |
---|
| 767 | Int i; |
---|
| 768 | UInt val; |
---|
| 769 | READ_UVLC( val, "tone_map_id" ); sei.m_toneMapId = val; |
---|
| 770 | READ_FLAG( val, "tone_map_cancel_flag" ); sei.m_toneMapCancelFlag = val; |
---|
| 771 | |
---|
| 772 | if ( !sei.m_toneMapCancelFlag ) |
---|
| 773 | { |
---|
| 774 | READ_FLAG( val, "tone_map_persistence_flag" ); sei.m_toneMapPersistenceFlag = val; |
---|
| 775 | READ_CODE( 8, val, "coded_data_bit_depth" ); sei.m_codedDataBitDepth = val; |
---|
| 776 | READ_CODE( 8, val, "target_bit_depth" ); sei.m_targetBitDepth = val; |
---|
| 777 | READ_UVLC( val, "model_id" ); sei.m_modelId = val; |
---|
| 778 | switch(sei.m_modelId) |
---|
| 779 | { |
---|
| 780 | case 0: |
---|
| 781 | { |
---|
| 782 | READ_CODE( 32, val, "min_value" ); sei.m_minValue = val; |
---|
| 783 | READ_CODE( 32, val, "max_value" ); sei.m_maxValue = val; |
---|
| 784 | break; |
---|
| 785 | } |
---|
| 786 | case 1: |
---|
| 787 | { |
---|
| 788 | READ_CODE( 32, val, "sigmoid_midpoint" ); sei.m_sigmoidMidpoint = val; |
---|
| 789 | READ_CODE( 32, val, "sigmoid_width" ); sei.m_sigmoidWidth = val; |
---|
| 790 | break; |
---|
| 791 | } |
---|
| 792 | case 2: |
---|
| 793 | { |
---|
| 794 | UInt num = 1u << sei.m_targetBitDepth; |
---|
| 795 | sei.m_startOfCodedInterval.resize(num+1); |
---|
| 796 | for(i = 0; i < num; i++) |
---|
| 797 | { |
---|
| 798 | READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval" ); |
---|
| 799 | sei.m_startOfCodedInterval[i] = val; |
---|
| 800 | } |
---|
| 801 | sei.m_startOfCodedInterval[num] = 1u << sei.m_codedDataBitDepth; |
---|
| 802 | break; |
---|
| 803 | } |
---|
| 804 | case 3: |
---|
| 805 | { |
---|
| 806 | READ_CODE( 16, val, "num_pivots" ); sei.m_numPivots = val; |
---|
| 807 | sei.m_codedPivotValue.resize(sei.m_numPivots); |
---|
| 808 | sei.m_targetPivotValue.resize(sei.m_numPivots); |
---|
| 809 | for(i = 0; i < sei.m_numPivots; i++ ) |
---|
| 810 | { |
---|
| 811 | READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value" ); |
---|
| 812 | sei.m_codedPivotValue[i] = val; |
---|
| 813 | READ_CODE( ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3), val, "target_pivot_value" ); |
---|
| 814 | sei.m_targetPivotValue[i] = val; |
---|
| 815 | } |
---|
| 816 | break; |
---|
| 817 | } |
---|
| 818 | case 4: |
---|
| 819 | { |
---|
[713] | 820 | READ_CODE( 8, val, "camera_iso_speed_idc" ); sei.m_cameraIsoSpeedIdc = val; |
---|
| 821 | if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO |
---|
[313] | 822 | { |
---|
| 823 | READ_CODE( 32, val, "camera_iso_speed_value" ); sei.m_cameraIsoSpeedValue = val; |
---|
| 824 | } |
---|
[713] | 825 | READ_CODE( 8, val, "exposure_index_idc" ); sei.m_exposureIndexIdc = val; |
---|
| 826 | if( sei.m_exposureIndexIdc == 255) //Extended_ISO |
---|
| 827 | { |
---|
| 828 | READ_CODE( 32, val, "exposure_index_value" ); sei.m_exposureIndexValue = val; |
---|
| 829 | } |
---|
[313] | 830 | READ_FLAG( val, "exposure_compensation_value_sign_flag" ); sei.m_exposureCompensationValueSignFlag = val; |
---|
| 831 | READ_CODE( 16, val, "exposure_compensation_value_numerator" ); sei.m_exposureCompensationValueNumerator = val; |
---|
| 832 | READ_CODE( 16, val, "exposure_compensation_value_denom_idc" ); sei.m_exposureCompensationValueDenomIdc = val; |
---|
| 833 | READ_CODE( 32, val, "ref_screen_luminance_white" ); sei.m_refScreenLuminanceWhite = val; |
---|
| 834 | READ_CODE( 32, val, "extended_range_white_level" ); sei.m_extendedRangeWhiteLevel = val; |
---|
| 835 | READ_CODE( 16, val, "nominal_black_level_luma_code_value" ); sei.m_nominalBlackLevelLumaCodeValue = val; |
---|
| 836 | READ_CODE( 16, val, "nominal_white_level_luma_code_value" ); sei.m_nominalWhiteLevelLumaCodeValue= val; |
---|
| 837 | READ_CODE( 16, val, "extended_white_level_luma_code_value" ); sei.m_extendedWhiteLevelLumaCodeValue = val; |
---|
| 838 | break; |
---|
| 839 | } |
---|
| 840 | default: |
---|
| 841 | { |
---|
| 842 | assert(!"Undefined SEIToneMapModelId"); |
---|
| 843 | break; |
---|
| 844 | } |
---|
| 845 | }//switch model id |
---|
| 846 | }// if(!sei.m_toneMapCancelFlag) |
---|
| 847 | |
---|
| 848 | xParseByteAlign(); |
---|
| 849 | } |
---|
| 850 | |
---|
[713] | 851 | #if Q0074_SEI_COLOR_MAPPING |
---|
| 852 | Void SEIReader::xParseSEIColorMappingInfo(SEIColorMappingInfo& sei, UInt /*payloadSize*/) |
---|
| 853 | { |
---|
| 854 | UInt uiVal; |
---|
| 855 | Int iVal; |
---|
| 856 | |
---|
| 857 | READ_UVLC( uiVal, "colour_map_id" ); sei.m_colorMapId = uiVal; |
---|
| 858 | READ_FLAG( uiVal, "colour_map_cancel_flag" ); sei.m_colorMapCancelFlag = uiVal; |
---|
| 859 | if( !sei.m_colorMapCancelFlag ) |
---|
| 860 | { |
---|
| 861 | READ_FLAG( uiVal, "colour_map_persistence_flag" ); sei.m_colorMapPersistenceFlag = uiVal; |
---|
| 862 | READ_FLAG( uiVal, "colour_map_video_signal_type_present_flag" ); sei.m_colorMap_video_signal_type_present_flag = uiVal; |
---|
| 863 | if ( sei.m_colorMap_video_signal_type_present_flag ) { |
---|
| 864 | READ_FLAG( uiVal, "colour_map_video_full_range_flag" ); sei.m_colorMap_video_full_range_flag = uiVal; |
---|
| 865 | READ_CODE( 8, uiVal, "colour_map_primaries" ); sei.m_colorMap_primaries = uiVal; |
---|
| 866 | READ_CODE( 8, uiVal, "colour_map_transfer_characteristics" ); sei.m_colorMap_transfer_characteristics = uiVal; |
---|
| 867 | READ_CODE( 8, uiVal, "colour_map_matrix_coeffs" ); sei.m_colorMap_matrix_coeffs = uiVal; |
---|
| 868 | } |
---|
| 869 | } |
---|
| 870 | |
---|
| 871 | READ_CODE( 5, uiVal, "colour_map_coded_data_bit_depth" ); sei.m_colour_map_coded_data_bit_depth = uiVal; |
---|
| 872 | READ_CODE( 5, uiVal, "colour_map_target_bit_depth" ); sei.m_colour_map_target_bit_depth = uiVal; |
---|
| 873 | READ_UVLC( uiVal, "colour_map_model_id" ); sei.m_colorMapModelId = uiVal; |
---|
| 874 | |
---|
| 875 | assert( sei.m_colorMapModelId == 0 ); |
---|
| 876 | |
---|
| 877 | for( Int i=0 ; i<3 ; i++ ) |
---|
| 878 | { |
---|
| 879 | READ_CODE( 8, uiVal, "num_input_pivots_minus1[i]" ); sei.m_num_input_pivots[i] = (uiVal==0) ? 2 : (uiVal + 1) ; |
---|
| 880 | sei.m_coded_input_pivot_value[i] = new Int[ sei.m_num_input_pivots[i] ]; |
---|
| 881 | sei.m_target_input_pivot_value[i] = new Int[ sei.m_num_input_pivots[i] ]; |
---|
| 882 | if( uiVal > 0 ) |
---|
| 883 | { |
---|
| 884 | for ( Int j=0 ; j<sei.m_num_input_pivots[i] ; j++ ) |
---|
| 885 | { |
---|
| 886 | READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "coded_input_pivot_value[i][j]" ); sei.m_coded_input_pivot_value[i][j] = uiVal; |
---|
| 887 | READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "target_input_pivot_value[i][j]" ); sei.m_target_input_pivot_value[i][j] = uiVal; |
---|
| 888 | } |
---|
| 889 | } |
---|
| 890 | else |
---|
| 891 | { |
---|
| 892 | sei.m_coded_input_pivot_value[i][0] = 0; |
---|
| 893 | sei.m_target_input_pivot_value[i][0] = 0; |
---|
| 894 | sei.m_coded_input_pivot_value[i][1] = (1 << sei.m_colour_map_coded_data_bit_depth) - 1 ; |
---|
| 895 | sei.m_target_input_pivot_value[i][1] = (1 << sei.m_colour_map_target_bit_depth) - 1 ; |
---|
| 896 | } |
---|
| 897 | } |
---|
| 898 | |
---|
| 899 | READ_FLAG( uiVal, "matrix_flag" ); sei.m_matrix_flag = uiVal; |
---|
| 900 | if( sei.m_matrix_flag ) |
---|
| 901 | { |
---|
| 902 | READ_CODE( 4, uiVal, "log2_matrix_denom" ); sei.m_log2_matrix_denom = uiVal; |
---|
| 903 | for ( Int i=0 ; i<3 ; i++ ) |
---|
| 904 | { |
---|
| 905 | for ( Int j=0 ; j<3 ; j++ ) |
---|
| 906 | { |
---|
| 907 | READ_SVLC( iVal, "matrix_coef[i][j]" ); sei.m_matrix_coef[i][j] = iVal; |
---|
| 908 | } |
---|
| 909 | } |
---|
| 910 | } |
---|
| 911 | |
---|
| 912 | for ( Int i=0 ; i<3 ; i++ ) |
---|
| 913 | { |
---|
| 914 | READ_CODE( 8, uiVal, "num_output_pivots_minus1[i]" ); sei.m_num_output_pivots[i] = (uiVal==0) ? 2 : (uiVal + 1) ; |
---|
| 915 | sei.m_coded_output_pivot_value[i] = new Int[ sei.m_num_output_pivots[i] ]; |
---|
| 916 | sei.m_target_output_pivot_value[i] = new Int[ sei.m_num_output_pivots[i] ]; |
---|
| 917 | if( uiVal > 0 ) |
---|
| 918 | { |
---|
| 919 | for ( Int j=0 ; j<sei.m_num_output_pivots[i] ; j++ ) |
---|
| 920 | { |
---|
| 921 | READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "coded_output_pivot_value[i][j]" ); sei.m_coded_output_pivot_value[i][j] = uiVal; |
---|
| 922 | READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "target_output_pivot_value[i][j]" ); sei.m_target_output_pivot_value[i][j] = uiVal; |
---|
| 923 | } |
---|
| 924 | } |
---|
| 925 | else |
---|
| 926 | { |
---|
| 927 | sei.m_coded_output_pivot_value[i][0] = 0; |
---|
| 928 | sei.m_target_output_pivot_value[i][0] = 0; |
---|
| 929 | sei.m_coded_output_pivot_value[i][1] = (1 << sei.m_colour_map_coded_data_bit_depth) - 1 ; |
---|
| 930 | sei.m_target_output_pivot_value[i][1] = (1 << sei.m_colour_map_target_bit_depth) - 1 ; |
---|
| 931 | } |
---|
| 932 | } |
---|
| 933 | |
---|
| 934 | xParseByteAlign(); |
---|
| 935 | } |
---|
| 936 | #endif |
---|
| 937 | |
---|
[313] | 938 | Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize) |
---|
| 939 | { |
---|
| 940 | Int iCode; |
---|
| 941 | UInt uiCode; |
---|
| 942 | |
---|
| 943 | READ_UVLC( uiCode, "sop_seq_parameter_set_id" ); sei.m_sopSeqParameterSetId = uiCode; |
---|
| 944 | READ_UVLC( uiCode, "num_pics_in_sop_minus1" ); sei.m_numPicsInSopMinus1 = uiCode; |
---|
| 945 | for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++) |
---|
| 946 | { |
---|
| 947 | READ_CODE( 6, uiCode, "sop_desc_vcl_nalu_type" ); sei.m_sopDescVclNaluType[i] = uiCode; |
---|
| 948 | READ_CODE( 3, sei.m_sopDescTemporalId[i], "sop_desc_temporal_id" ); sei.m_sopDescTemporalId[i] = uiCode; |
---|
| 949 | if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP) |
---|
| 950 | { |
---|
| 951 | READ_UVLC( sei.m_sopDescStRpsIdx[i], "sop_desc_st_rps_idx" ); sei.m_sopDescStRpsIdx[i] = uiCode; |
---|
| 952 | } |
---|
| 953 | if (i > 0) |
---|
| 954 | { |
---|
| 955 | READ_SVLC( iCode, "sop_desc_poc_delta" ); sei.m_sopDescPocDelta[i] = iCode; |
---|
| 956 | } |
---|
| 957 | } |
---|
| 958 | |
---|
| 959 | xParseByteAlign(); |
---|
| 960 | } |
---|
| 961 | |
---|
[588] | 962 | #if LAYERS_NOT_PRESENT_SEI |
---|
[313] | 963 | Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComVPS *vps, TComSPS *sps) |
---|
| 964 | #else |
---|
| 965 | Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComSPS *sps) |
---|
| 966 | #endif |
---|
| 967 | { |
---|
| 968 | UInt uiCode; |
---|
| 969 | SEIMessages seis; |
---|
| 970 | |
---|
| 971 | READ_FLAG( uiCode, "bitstream_subset_flag" ); sei.m_bitStreamSubsetFlag = uiCode; |
---|
| 972 | READ_FLAG( uiCode, "nesting_op_flag" ); sei.m_nestingOpFlag = uiCode; |
---|
| 973 | if (sei.m_nestingOpFlag) |
---|
| 974 | { |
---|
| 975 | READ_FLAG( uiCode, "default_op_flag" ); sei.m_defaultOpFlag = uiCode; |
---|
| 976 | READ_UVLC( uiCode, "nesting_num_ops_minus1" ); sei.m_nestingNumOpsMinus1 = uiCode; |
---|
| 977 | for (UInt i = sei.m_defaultOpFlag; i <= sei.m_nestingNumOpsMinus1; i++) |
---|
| 978 | { |
---|
| 979 | READ_CODE( 3, uiCode, "nesting_max_temporal_id_plus1" ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode; |
---|
| 980 | READ_UVLC( uiCode, "nesting_op_idx" ); sei.m_nestingOpIdx[i] = uiCode; |
---|
| 981 | } |
---|
| 982 | } |
---|
| 983 | else |
---|
| 984 | { |
---|
| 985 | READ_FLAG( uiCode, "all_layers_flag" ); sei.m_allLayersFlag = uiCode; |
---|
| 986 | if (!sei.m_allLayersFlag) |
---|
| 987 | { |
---|
| 988 | READ_CODE( 3, uiCode, "nesting_no_op_max_temporal_id_plus1" ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode; |
---|
| 989 | READ_UVLC( uiCode, "nesting_num_layers_minus1" ); sei.m_nestingNumLayersMinus1 = uiCode; |
---|
| 990 | for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++) |
---|
| 991 | { |
---|
| 992 | READ_CODE( 6, uiCode, "nesting_layer_id" ); sei.m_nestingLayerId[i] = uiCode; |
---|
| 993 | } |
---|
| 994 | } |
---|
| 995 | } |
---|
| 996 | |
---|
| 997 | // byte alignment |
---|
| 998 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
| 999 | { |
---|
| 1000 | UInt code; |
---|
| 1001 | READ_FLAG( code, "nesting_zero_bit" ); |
---|
| 1002 | } |
---|
| 1003 | |
---|
| 1004 | sei.m_callerOwnsSEIs = false; |
---|
| 1005 | |
---|
| 1006 | // read nested SEI messages |
---|
| 1007 | do { |
---|
[644] | 1008 | #if O0164_MULTI_LAYER_HRD |
---|
[588] | 1009 | #if LAYERS_NOT_PRESENT_SEI |
---|
[644] | 1010 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, &sei); |
---|
| 1011 | #else |
---|
| 1012 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, &sei); |
---|
| 1013 | #endif |
---|
| 1014 | #else |
---|
| 1015 | #if LAYERS_NOT_PRESENT_SEI |
---|
[313] | 1016 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps); |
---|
| 1017 | #else |
---|
| 1018 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps); |
---|
| 1019 | #endif |
---|
[644] | 1020 | #endif |
---|
[313] | 1021 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
---|
| 1022 | |
---|
| 1023 | } |
---|
| 1024 | |
---|
| 1025 | Void SEIReader::xParseByteAlign() |
---|
| 1026 | { |
---|
| 1027 | UInt code; |
---|
| 1028 | if( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
| 1029 | { |
---|
| 1030 | READ_FLAG( code, "bit_equal_to_one" ); assert( code == 1 ); |
---|
| 1031 | } |
---|
| 1032 | while( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
| 1033 | { |
---|
| 1034 | READ_FLAG( code, "bit_equal_to_zero" ); assert( code == 0 ); |
---|
| 1035 | } |
---|
| 1036 | } |
---|
[595] | 1037 | |
---|
| 1038 | #if SVC_EXTENSION |
---|
| 1039 | #if LAYERS_NOT_PRESENT_SEI |
---|
| 1040 | Void SEIReader::xParseSEILayersNotPresent(SEILayersNotPresent &sei, UInt payloadSize, TComVPS *vps) |
---|
| 1041 | { |
---|
| 1042 | UInt uiCode; |
---|
| 1043 | UInt i = 0; |
---|
| 1044 | |
---|
| 1045 | READ_UVLC( uiCode, "lp_sei_active_vps_id" ); sei.m_activeVpsId = uiCode; |
---|
| 1046 | assert(vps->getVPSId() == sei.m_activeVpsId); |
---|
| 1047 | sei.m_vpsMaxLayers = vps->getMaxLayers(); |
---|
| 1048 | for (; i < sei.m_vpsMaxLayers; i++) |
---|
| 1049 | { |
---|
| 1050 | READ_FLAG( uiCode, "layer_not_present_flag" ); sei.m_layerNotPresentFlag[i] = uiCode ? true : false; |
---|
| 1051 | } |
---|
| 1052 | for (; i < MAX_LAYERS; i++) |
---|
| 1053 | { |
---|
| 1054 | sei.m_layerNotPresentFlag[i] = false; |
---|
| 1055 | } |
---|
| 1056 | xParseByteAlign(); |
---|
| 1057 | } |
---|
| 1058 | #endif |
---|
| 1059 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
| 1060 | Void SEIReader::xParseSEIInterLayerConstrainedTileSets (SEIInterLayerConstrainedTileSets &sei, UInt payloadSize) |
---|
| 1061 | { |
---|
| 1062 | UInt uiCode; |
---|
| 1063 | |
---|
| 1064 | READ_FLAG( uiCode, "il_all_tiles_exact_sample_value_match_flag" ); sei.m_ilAllTilesExactSampleValueMatchFlag = uiCode; |
---|
| 1065 | READ_FLAG( uiCode, "il_one_tile_per_tile_set_flag" ); sei.m_ilOneTilePerTileSetFlag = uiCode; |
---|
| 1066 | if( !sei.m_ilOneTilePerTileSetFlag ) |
---|
| 1067 | { |
---|
| 1068 | READ_UVLC( uiCode, "il_num_sets_in_message_minus1" ); sei.m_ilNumSetsInMessageMinus1 = uiCode; |
---|
| 1069 | if( sei.m_ilNumSetsInMessageMinus1 ) |
---|
| 1070 | { |
---|
| 1071 | READ_FLAG( uiCode, "skipped_tile_set_present_flag" ); sei.m_skippedTileSetPresentFlag = uiCode; |
---|
| 1072 | } |
---|
| 1073 | else |
---|
| 1074 | { |
---|
| 1075 | sei.m_skippedTileSetPresentFlag = false; |
---|
| 1076 | } |
---|
| 1077 | UInt numSignificantSets = sei.m_ilNumSetsInMessageMinus1 - (sei.m_skippedTileSetPresentFlag ? 1 : 0) + 1; |
---|
| 1078 | for( UInt i = 0; i < numSignificantSets; i++ ) |
---|
| 1079 | { |
---|
| 1080 | READ_UVLC( uiCode, "ilcts_id" ); sei.m_ilctsId[i] = uiCode; |
---|
| 1081 | READ_UVLC( uiCode, "il_num_tile_rects_in_set_minus1" ) ;sei.m_ilNumTileRectsInSetMinus1[i] = uiCode; |
---|
| 1082 | for( UInt j = 0; j <= sei.m_ilNumTileRectsInSetMinus1[i]; j++ ) |
---|
| 1083 | { |
---|
| 1084 | READ_UVLC( uiCode, "il_top_left_tile_index" ); sei.m_ilTopLeftTileIndex[i][j] = uiCode; |
---|
| 1085 | READ_UVLC( uiCode, "il_bottom_right_tile_index" ); sei.m_ilBottomRightTileIndex[i][j] = uiCode; |
---|
| 1086 | } |
---|
| 1087 | READ_CODE( 2, uiCode, "ilc_idc" ); sei.m_ilcIdc[i] = uiCode; |
---|
| 1088 | if( sei.m_ilAllTilesExactSampleValueMatchFlag ) |
---|
| 1089 | { |
---|
| 1090 | READ_FLAG( uiCode, "il_exact_sample_value_match_flag" ); sei.m_ilExactSampleValueMatchFlag[i] = uiCode; |
---|
| 1091 | } |
---|
| 1092 | } |
---|
| 1093 | } |
---|
| 1094 | else |
---|
| 1095 | { |
---|
| 1096 | READ_CODE( 2, uiCode, "all_tiles_ilc_idc" ); sei.m_allTilesIlcIdc = uiCode; |
---|
| 1097 | } |
---|
| 1098 | |
---|
| 1099 | xParseByteAlign(); |
---|
| 1100 | } |
---|
| 1101 | #endif |
---|
| 1102 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
| 1103 | Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei) |
---|
| 1104 | { |
---|
| 1105 | UInt uiCode; |
---|
| 1106 | READ_CODE( 4, uiCode, "active_vps_id" ); sei.m_activeVpsId = uiCode; |
---|
| 1107 | READ_UVLC( uiCode, "num_additional_sub_streams_minus1" ); sei.m_numAdditionalSubStreams = uiCode + 1; |
---|
| 1108 | |
---|
| 1109 | for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ ) |
---|
| 1110 | { |
---|
| 1111 | READ_CODE( 2, uiCode, "sub_bitstream_mode[i]" ); sei.m_subBitstreamMode[i] = uiCode; |
---|
| 1112 | READ_UVLC( uiCode, "output_layer_set_idx_to_vps[i]" ); sei.m_outputLayerSetIdxToVps[i] = uiCode; |
---|
| 1113 | READ_CODE( 3, uiCode, "highest_sub_layer_id[i]" ); sei.m_highestSublayerId[i] = uiCode; |
---|
| 1114 | READ_CODE( 16, uiCode, "avg_bit_rate[i]" ); sei.m_avgBitRate[i] = uiCode; |
---|
| 1115 | READ_CODE( 16, uiCode, "max_bit_rate[i]" ); sei.m_maxBitRate[i] = uiCode; |
---|
| 1116 | } |
---|
| 1117 | xParseByteAlign(); |
---|
| 1118 | } |
---|
| 1119 | #endif |
---|
[644] | 1120 | |
---|
| 1121 | #if O0164_MULTI_LAYER_HRD |
---|
| 1122 | #if LAYERS_NOT_PRESENT_SEI |
---|
| 1123 | Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei) |
---|
| 1124 | #else |
---|
| 1125 | Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, TComSPS *sps, const SEIScalableNesting &nestingSei) |
---|
| 1126 | #endif |
---|
| 1127 | { |
---|
| 1128 | UInt uiCode; |
---|
| 1129 | READ_UVLC( uiCode, "bsp_idx" ); sei.m_bspIdx = uiCode; |
---|
| 1130 | |
---|
| 1131 | // byte alignment |
---|
| 1132 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
| 1133 | { |
---|
| 1134 | UInt code; |
---|
| 1135 | READ_FLAG( code, "bsp_nesting_zero_bit" ); |
---|
| 1136 | } |
---|
| 1137 | |
---|
| 1138 | sei.m_callerOwnsSEIs = false; |
---|
| 1139 | |
---|
| 1140 | // read nested SEI messages |
---|
| 1141 | do { |
---|
| 1142 | #if LAYERS_NOT_PRESENT_SEI |
---|
| 1143 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, &nestingSei, &sei); |
---|
| 1144 | #else |
---|
| 1145 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, &nestingSei); |
---|
| 1146 | #endif |
---|
| 1147 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
---|
| 1148 | } |
---|
| 1149 | |
---|
| 1150 | Void SEIReader::xParseSEIBspInitialArrivalTime(SEIBspInitialArrivalTime &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei) |
---|
| 1151 | { |
---|
| 1152 | assert(vps->getVpsVuiPresentFlag()); |
---|
| 1153 | |
---|
| 1154 | UInt schedCombCnt = vps->getNumBspSchedCombinations(nestingSei.m_nestingOpIdx[0]); |
---|
| 1155 | UInt len; |
---|
| 1156 | UInt hrdIdx; |
---|
| 1157 | UInt uiCode; |
---|
| 1158 | |
---|
| 1159 | if (schedCombCnt > 0) |
---|
| 1160 | { |
---|
| 1161 | hrdIdx = vps->getBspCombHrdIdx(nestingSei.m_nestingOpIdx[0], 0, bspNestingSei.m_bspIdx); |
---|
| 1162 | } |
---|
| 1163 | else |
---|
| 1164 | { |
---|
| 1165 | hrdIdx = 0; |
---|
| 1166 | } |
---|
| 1167 | |
---|
| 1168 | TComHRD *hrd = vps->getBspHrd(hrdIdx); |
---|
| 1169 | |
---|
| 1170 | if (hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag()) |
---|
| 1171 | { |
---|
| 1172 | len = hrd->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
| 1173 | } |
---|
| 1174 | else |
---|
| 1175 | { |
---|
| 1176 | len = 23 + 1; |
---|
| 1177 | } |
---|
| 1178 | |
---|
| 1179 | if (hrd->getNalHrdParametersPresentFlag()) |
---|
| 1180 | { |
---|
| 1181 | for(UInt i = 0; i < schedCombCnt; i++) |
---|
| 1182 | { |
---|
| 1183 | READ_CODE( len, uiCode, "nal_initial_arrival_delay" ); sei.m_nalInitialArrivalDelay[i] = uiCode; |
---|
| 1184 | } |
---|
| 1185 | } |
---|
| 1186 | else |
---|
| 1187 | { |
---|
| 1188 | for(UInt i = 0; i < schedCombCnt; i++) |
---|
| 1189 | { |
---|
| 1190 | READ_CODE( len, uiCode, "vcl_initial_arrival_delay" ); sei.m_vclInitialArrivalDelay[i] = uiCode; |
---|
| 1191 | } |
---|
| 1192 | } |
---|
| 1193 | } |
---|
| 1194 | |
---|
| 1195 | Void SEIReader::xParseSEIBspHrd(SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei) |
---|
| 1196 | { |
---|
| 1197 | UInt uiCode; |
---|
| 1198 | READ_UVLC( uiCode, "sei_num_bsp_hrd_parameters_minus1" ); sei.m_seiNumBspHrdParametersMinus1 = uiCode; |
---|
| 1199 | for (UInt i = 0; i <= sei.m_seiNumBspHrdParametersMinus1; i++) |
---|
| 1200 | { |
---|
| 1201 | if (i > 0) |
---|
| 1202 | { |
---|
| 1203 | READ_FLAG( uiCode, "sei_bsp_cprms_present_flag" ); sei.m_seiBspCprmsPresentFlag[i] = uiCode; |
---|
| 1204 | } |
---|
| 1205 | xParseHrdParameters(sei.hrd, i==0 ? 1 : sei.m_seiBspCprmsPresentFlag[i], nestingSei.m_nestingMaxTemporalIdPlus1[0]-1); |
---|
| 1206 | } |
---|
| 1207 | for (UInt h = 0; h <= nestingSei.m_nestingNumOpsMinus1; h++) |
---|
| 1208 | { |
---|
| 1209 | UInt lsIdx = nestingSei.m_nestingOpIdx[h]; |
---|
| 1210 | READ_UVLC( uiCode, "num_sei_bitstream_partitions_minus1[i]"); sei.m_seiNumBitstreamPartitionsMinus1[lsIdx] = uiCode; |
---|
| 1211 | for (UInt i = 0; i <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; i++) |
---|
| 1212 | { |
---|
| 1213 | for (UInt j = 0; j < sei.m_vpsMaxLayers; j++) |
---|
| 1214 | { |
---|
| 1215 | if (sei.m_layerIdIncludedFlag[lsIdx][j]) |
---|
| 1216 | { |
---|
| 1217 | READ_FLAG( uiCode, "sei_layer_in_bsp_flag[lsIdx][i][j]" ); sei.m_seiLayerInBspFlag[lsIdx][i][j] = uiCode; |
---|
| 1218 | } |
---|
| 1219 | } |
---|
| 1220 | } |
---|
| 1221 | READ_UVLC( uiCode, "sei_num_bsp_sched_combinations_minus1[i]"); sei.m_seiNumBspSchedCombinationsMinus1[lsIdx] = uiCode; |
---|
| 1222 | for (UInt i = 0; i <= sei.m_seiNumBspSchedCombinationsMinus1[lsIdx]; i++) |
---|
| 1223 | { |
---|
| 1224 | for (UInt j = 0; j <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; j++) |
---|
| 1225 | { |
---|
| 1226 | READ_UVLC( uiCode, "sei_bsp_comb_hrd_idx[lsIdx][i][j]"); sei.m_seiBspCombHrdIdx[lsIdx][i][j] = uiCode; |
---|
| 1227 | READ_UVLC( uiCode, "sei_bsp_comb_sched_idx[lsIdx][i][j]"); sei.m_seiBspCombScheddx[lsIdx][i][j] = uiCode; |
---|
| 1228 | } |
---|
| 1229 | } |
---|
| 1230 | } |
---|
| 1231 | } |
---|
| 1232 | |
---|
| 1233 | Void SEIReader::xParseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1) |
---|
| 1234 | { |
---|
| 1235 | UInt uiCode; |
---|
| 1236 | if( commonInfPresentFlag ) |
---|
| 1237 | { |
---|
| 1238 | READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
| 1239 | READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
| 1240 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
| 1241 | { |
---|
| 1242 | READ_FLAG( uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
---|
| 1243 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 1244 | { |
---|
| 1245 | READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
---|
| 1246 | READ_CODE( 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 1247 | READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
---|
| 1248 | READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
---|
| 1249 | } |
---|
| 1250 | READ_CODE( 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
---|
| 1251 | READ_CODE( 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
---|
| 1252 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 1253 | { |
---|
| 1254 | READ_CODE( 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
---|
| 1255 | } |
---|
| 1256 | READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 1257 | READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 1258 | READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
---|
| 1259 | } |
---|
| 1260 | } |
---|
| 1261 | Int i, j, nalOrVcl; |
---|
| 1262 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
| 1263 | { |
---|
| 1264 | READ_FLAG( uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
---|
| 1265 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
| 1266 | { |
---|
| 1267 | READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
---|
| 1268 | } |
---|
| 1269 | else |
---|
| 1270 | { |
---|
| 1271 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
| 1272 | } |
---|
| 1273 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
---|
| 1274 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
---|
| 1275 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
| 1276 | { |
---|
| 1277 | READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
---|
| 1278 | } |
---|
| 1279 | else |
---|
| 1280 | { |
---|
| 1281 | READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
---|
| 1282 | } |
---|
| 1283 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
| 1284 | { |
---|
| 1285 | READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
---|
| 1286 | } |
---|
| 1287 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
| 1288 | { |
---|
| 1289 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
| 1290 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
| 1291 | { |
---|
| 1292 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
| 1293 | { |
---|
| 1294 | READ_UVLC( uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 1295 | READ_UVLC( uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 1296 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 1297 | { |
---|
| 1298 | READ_UVLC( uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 1299 | READ_UVLC( uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 1300 | } |
---|
| 1301 | READ_FLAG( uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
---|
| 1302 | } |
---|
| 1303 | } |
---|
| 1304 | } |
---|
| 1305 | } |
---|
| 1306 | } |
---|
| 1307 | #endif |
---|
| 1308 | |
---|
[595] | 1309 | #endif //SVC_EXTENSION |
---|
| 1310 | |
---|
[313] | 1311 | //! \} |
---|