[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; |
---|
[815] | 95 | #if P0050_KNEE_FUNCTION_SEI |
---|
| 96 | case SEI::KNEE_FUNCTION_INFO: |
---|
| 97 | fprintf( g_hTrace, "=========== Knee Function Information SEI message ===========\n"); |
---|
| 98 | break; |
---|
| 99 | #endif |
---|
[713] | 100 | #if Q0074_SEI_COLOR_MAPPING |
---|
| 101 | case SEI::COLOR_MAPPING_INFO: |
---|
| 102 | fprintf( g_hTrace, "===========Color Mapping Info SEI message ===========\n"); |
---|
| 103 | break; |
---|
| 104 | #endif |
---|
[595] | 105 | case SEI::SOP_DESCRIPTION: |
---|
| 106 | fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n"); |
---|
| 107 | break; |
---|
| 108 | case SEI::SCALABLE_NESTING: |
---|
| 109 | fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n"); |
---|
| 110 | break; |
---|
| 111 | #if SVC_EXTENSION |
---|
[588] | 112 | #if LAYERS_NOT_PRESENT_SEI |
---|
| 113 | case SEI::LAYERS_NOT_PRESENT: |
---|
[313] | 114 | fprintf( g_hTrace, "=========== Layers Present SEI message ===========\n"); |
---|
| 115 | break; |
---|
| 116 | #endif |
---|
[442] | 117 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
| 118 | case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: |
---|
| 119 | fprintf( g_hTrace, "=========== Inter Layer Constrained Tile Sets SEI message ===========\n"); |
---|
| 120 | break; |
---|
| 121 | #endif |
---|
[588] | 122 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
[644] | 123 | case SEI::SUB_BITSTREAM_PROPERTY: |
---|
| 124 | fprintf( g_hTrace, "=========== Sub-bitstream property SEI message ===========\n"); |
---|
| 125 | break; |
---|
[588] | 126 | #endif |
---|
[644] | 127 | #if O0164_MULTI_LAYER_HRD |
---|
| 128 | case SEI::BSP_NESTING: |
---|
| 129 | fprintf( g_hTrace, "=========== Bitstream parition nesting SEI message ===========\n"); |
---|
| 130 | break; |
---|
| 131 | case SEI::BSP_INITIAL_ARRIVAL_TIME: |
---|
| 132 | fprintf( g_hTrace, "=========== Bitstream parition initial arrival time SEI message ===========\n"); |
---|
| 133 | break; |
---|
| 134 | case SEI::BSP_HRD: |
---|
| 135 | fprintf( g_hTrace, "=========== Bitstream parition HRD parameters SEI message ===========\n"); |
---|
| 136 | break; |
---|
| 137 | #endif |
---|
[815] | 138 | #if Q0078_ADD_LAYER_SETS |
---|
| 139 | case SEI::OUTPUT_LAYER_SET_NESTING: |
---|
| 140 | fprintf(g_hTrace, "=========== Output layer set nesting SEI message ===========\n"); |
---|
| 141 | break; |
---|
| 142 | case SEI::VPS_REWRITING: |
---|
| 143 | fprintf(g_hTrace, "=========== VPS rewriting SEI message ===========\n"); |
---|
| 144 | break; |
---|
| 145 | #endif |
---|
[595] | 146 | #endif //SVC_EXTENSION |
---|
[313] | 147 | default: |
---|
| 148 | fprintf( g_hTrace, "=========== Unknown SEI message ===========\n"); |
---|
| 149 | break; |
---|
| 150 | } |
---|
| 151 | } |
---|
| 152 | #endif |
---|
| 153 | |
---|
| 154 | /** |
---|
| 155 | * unmarshal a single SEI message from bitstream bs |
---|
| 156 | */ |
---|
[588] | 157 | #if LAYERS_NOT_PRESENT_SEI |
---|
[313] | 158 | void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps) |
---|
| 159 | #else |
---|
| 160 | void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps) |
---|
| 161 | #endif |
---|
| 162 | { |
---|
| 163 | setBitstream(bs); |
---|
| 164 | |
---|
| 165 | assert(!m_pcBitstream->getNumBitsUntilByteAligned()); |
---|
| 166 | do |
---|
| 167 | { |
---|
[588] | 168 | #if LAYERS_NOT_PRESENT_SEI |
---|
[313] | 169 | xReadSEImessage(seis, nalUnitType, vps, sps); |
---|
| 170 | #else |
---|
| 171 | xReadSEImessage(seis, nalUnitType, sps); |
---|
| 172 | #endif |
---|
| 173 | /* SEI messages are an integer number of bytes, something has failed |
---|
| 174 | * in the parsing if bitstream not byte-aligned */ |
---|
| 175 | assert(!m_pcBitstream->getNumBitsUntilByteAligned()); |
---|
| 176 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
---|
| 177 | |
---|
| 178 | UInt rbspTrailingBits; |
---|
| 179 | READ_CODE(8, rbspTrailingBits, "rbsp_trailing_bits"); |
---|
| 180 | assert(rbspTrailingBits == 0x80); |
---|
| 181 | } |
---|
| 182 | |
---|
[644] | 183 | #if O0164_MULTI_LAYER_HRD |
---|
[588] | 184 | #if LAYERS_NOT_PRESENT_SEI |
---|
[644] | 185 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, const SEIScalableNesting *nestingSei, const SEIBspNesting *bspNestingSei) |
---|
| 186 | #else |
---|
| 187 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps, const SEIScalableNesting *nestingSei) |
---|
| 188 | #endif |
---|
| 189 | #else |
---|
| 190 | #if LAYERS_NOT_PRESENT_SEI |
---|
[313] | 191 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps) |
---|
| 192 | #else |
---|
| 193 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps) |
---|
| 194 | #endif |
---|
[644] | 195 | #endif |
---|
[313] | 196 | { |
---|
| 197 | #if ENC_DEC_TRACE |
---|
| 198 | xTraceSEIHeader(); |
---|
| 199 | #endif |
---|
| 200 | Int payloadType = 0; |
---|
| 201 | UInt val = 0; |
---|
| 202 | |
---|
| 203 | do |
---|
| 204 | { |
---|
| 205 | READ_CODE (8, val, "payload_type"); |
---|
| 206 | payloadType += val; |
---|
| 207 | } while (val==0xFF); |
---|
| 208 | |
---|
| 209 | UInt payloadSize = 0; |
---|
| 210 | do |
---|
| 211 | { |
---|
| 212 | READ_CODE (8, val, "payload_size"); |
---|
| 213 | payloadSize += val; |
---|
| 214 | } while (val==0xFF); |
---|
| 215 | |
---|
| 216 | #if ENC_DEC_TRACE |
---|
| 217 | xTraceSEIMessageType((SEI::PayloadType)payloadType); |
---|
| 218 | #endif |
---|
| 219 | |
---|
| 220 | /* extract the payload for this single SEI message. |
---|
| 221 | * This allows greater safety in erroneous parsing of an SEI message |
---|
| 222 | * from affecting subsequent messages. |
---|
| 223 | * After parsing the payload, bs needs to be restored as the primary |
---|
| 224 | * bitstream. |
---|
| 225 | */ |
---|
| 226 | TComInputBitstream *bs = getBitstream(); |
---|
| 227 | setBitstream(bs->extractSubstream(payloadSize * 8)); |
---|
| 228 | |
---|
| 229 | SEI *sei = NULL; |
---|
| 230 | |
---|
| 231 | if(nalUnitType == NAL_UNIT_PREFIX_SEI) |
---|
| 232 | { |
---|
| 233 | switch (payloadType) |
---|
| 234 | { |
---|
| 235 | case SEI::USER_DATA_UNREGISTERED: |
---|
| 236 | sei = new SEIuserDataUnregistered; |
---|
| 237 | xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize); |
---|
| 238 | break; |
---|
| 239 | case SEI::ACTIVE_PARAMETER_SETS: |
---|
| 240 | sei = new SEIActiveParameterSets; |
---|
| 241 | xParseSEIActiveParameterSets((SEIActiveParameterSets&) *sei, payloadSize); |
---|
| 242 | break; |
---|
| 243 | case SEI::DECODING_UNIT_INFO: |
---|
| 244 | if (!sps) |
---|
| 245 | { |
---|
| 246 | printf ("Warning: Found Decoding unit SEI message, but no active SPS is available. Ignoring."); |
---|
| 247 | } |
---|
| 248 | else |
---|
| 249 | { |
---|
| 250 | sei = new SEIDecodingUnitInfo; |
---|
| 251 | xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps); |
---|
| 252 | } |
---|
| 253 | break; |
---|
| 254 | case SEI::BUFFERING_PERIOD: |
---|
| 255 | if (!sps) |
---|
| 256 | { |
---|
| 257 | printf ("Warning: Found Buffering period SEI message, but no active SPS is available. Ignoring."); |
---|
| 258 | } |
---|
| 259 | else |
---|
| 260 | { |
---|
| 261 | sei = new SEIBufferingPeriod; |
---|
| 262 | xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps); |
---|
| 263 | } |
---|
| 264 | break; |
---|
| 265 | case SEI::PICTURE_TIMING: |
---|
| 266 | if (!sps) |
---|
| 267 | { |
---|
| 268 | printf ("Warning: Found Picture timing SEI message, but no active SPS is available. Ignoring."); |
---|
| 269 | } |
---|
| 270 | else |
---|
| 271 | { |
---|
| 272 | sei = new SEIPictureTiming; |
---|
| 273 | xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps); |
---|
| 274 | } |
---|
| 275 | break; |
---|
| 276 | case SEI::RECOVERY_POINT: |
---|
| 277 | sei = new SEIRecoveryPoint; |
---|
| 278 | xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize); |
---|
| 279 | break; |
---|
| 280 | case SEI::FRAME_PACKING: |
---|
| 281 | sei = new SEIFramePacking; |
---|
| 282 | xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize); |
---|
| 283 | break; |
---|
| 284 | case SEI::DISPLAY_ORIENTATION: |
---|
| 285 | sei = new SEIDisplayOrientation; |
---|
| 286 | xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize); |
---|
| 287 | break; |
---|
| 288 | case SEI::TEMPORAL_LEVEL0_INDEX: |
---|
| 289 | sei = new SEITemporalLevel0Index; |
---|
| 290 | xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize); |
---|
| 291 | break; |
---|
| 292 | case SEI::REGION_REFRESH_INFO: |
---|
| 293 | sei = new SEIGradualDecodingRefreshInfo; |
---|
| 294 | xParseSEIGradualDecodingRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize); |
---|
| 295 | break; |
---|
| 296 | case SEI::TONE_MAPPING_INFO: |
---|
| 297 | sei = new SEIToneMappingInfo; |
---|
| 298 | xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize); |
---|
| 299 | break; |
---|
[815] | 300 | #if P0050_KNEE_FUNCTION_SEI |
---|
| 301 | case SEI::KNEE_FUNCTION_INFO: |
---|
| 302 | sei = new SEIKneeFunctionInfo; |
---|
| 303 | xParseSEIKneeFunctionInfo((SEIKneeFunctionInfo&) *sei, payloadSize); |
---|
| 304 | break; |
---|
| 305 | #endif |
---|
[713] | 306 | #if Q0074_SEI_COLOR_MAPPING |
---|
| 307 | case SEI::COLOR_MAPPING_INFO: |
---|
| 308 | sei = new SEIColorMappingInfo; |
---|
| 309 | xParseSEIColorMappingInfo((SEIColorMappingInfo&) *sei, payloadSize); |
---|
| 310 | break; |
---|
| 311 | #endif |
---|
[595] | 312 | case SEI::SOP_DESCRIPTION: |
---|
| 313 | sei = new SEISOPDescription; |
---|
| 314 | xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize); |
---|
| 315 | break; |
---|
| 316 | case SEI::SCALABLE_NESTING: |
---|
| 317 | sei = new SEIScalableNesting; |
---|
[588] | 318 | #if LAYERS_NOT_PRESENT_SEI |
---|
[595] | 319 | xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, vps, sps); |
---|
| 320 | #else |
---|
| 321 | xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps); |
---|
| 322 | #endif |
---|
[644] | 323 | break; |
---|
[595] | 324 | #if SVC_EXTENSION |
---|
| 325 | #if LAYERS_NOT_PRESENT_SEI |
---|
[588] | 326 | case SEI::LAYERS_NOT_PRESENT: |
---|
[313] | 327 | if (!vps) |
---|
| 328 | { |
---|
[588] | 329 | printf ("Warning: Found Layers not present SEI message, but no active VPS is available. Ignoring."); |
---|
[313] | 330 | } |
---|
| 331 | else |
---|
| 332 | { |
---|
[588] | 333 | sei = new SEILayersNotPresent; |
---|
| 334 | xParseSEILayersNotPresent((SEILayersNotPresent&) *sei, payloadSize, vps); |
---|
[313] | 335 | } |
---|
| 336 | break; |
---|
| 337 | #endif |
---|
[442] | 338 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
| 339 | case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: |
---|
| 340 | sei = new SEIInterLayerConstrainedTileSets; |
---|
| 341 | xParseSEIInterLayerConstrainedTileSets((SEIInterLayerConstrainedTileSets&) *sei, payloadSize); |
---|
| 342 | break; |
---|
| 343 | #endif |
---|
[588] | 344 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
| 345 | case SEI::SUB_BITSTREAM_PROPERTY: |
---|
| 346 | sei = new SEISubBitstreamProperty; |
---|
| 347 | xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei); |
---|
| 348 | break; |
---|
| 349 | #endif |
---|
[644] | 350 | #if O0164_MULTI_LAYER_HRD |
---|
| 351 | case SEI::BSP_NESTING: |
---|
| 352 | sei = new SEIBspNesting; |
---|
| 353 | #if LAYERS_NOT_PRESENT_SEI |
---|
| 354 | xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, vps, sps, *nestingSei); |
---|
| 355 | #else |
---|
| 356 | xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, sps, *nestingSei); |
---|
| 357 | #endif |
---|
| 358 | break; |
---|
| 359 | case SEI::BSP_INITIAL_ARRIVAL_TIME: |
---|
| 360 | sei = new SEIBspInitialArrivalTime; |
---|
| 361 | xParseSEIBspInitialArrivalTime((SEIBspInitialArrivalTime&) *sei, vps, sps, *nestingSei, *bspNestingSei); |
---|
| 362 | break; |
---|
[846] | 363 | #if !REMOVE_BSP_HRD_SEI |
---|
[644] | 364 | case SEI::BSP_HRD: |
---|
| 365 | sei = new SEIBspHrd; |
---|
| 366 | xParseSEIBspHrd((SEIBspHrd&) *sei, sps, *nestingSei); |
---|
| 367 | break; |
---|
| 368 | #endif |
---|
[846] | 369 | #endif |
---|
[815] | 370 | #if Q0078_ADD_LAYER_SETS |
---|
| 371 | case SEI::OUTPUT_LAYER_SET_NESTING: |
---|
| 372 | sei = new SEIOutputLayerSetNesting; |
---|
| 373 | #if LAYERS_NOT_PRESENT_SEI |
---|
| 374 | xParseSEIOutputLayerSetNesting((SEIOutputLayerSetNesting&)*sei, nalUnitType, vps, sps); |
---|
| 375 | #else |
---|
| 376 | xParseSEIOutputLayerSetNesting((SEIOutputLayerSetNesting&)*sei, nalUnitType, sps); |
---|
| 377 | #endif |
---|
| 378 | break; |
---|
| 379 | case SEI::VPS_REWRITING: |
---|
| 380 | sei = new SEIVPSRewriting; |
---|
| 381 | xParseSEIVPSRewriting((SEIVPSRewriting&)*sei); |
---|
| 382 | break; |
---|
| 383 | #endif |
---|
| 384 | #if Q0189_TMVP_CONSTRAINTS |
---|
| 385 | case SEI::TMVP_CONSTRAINTS: |
---|
| 386 | sei = new SEITMVPConstrains; |
---|
| 387 | xParseSEITMVPConstraints((SEITMVPConstrains&) *sei, payloadSize); |
---|
| 388 | break; |
---|
| 389 | #endif |
---|
| 390 | #if Q0247_FRAME_FIELD_INFO |
---|
| 391 | case SEI::FRAME_FIELD_INFO: |
---|
| 392 | sei = new SEIFrameFieldInfo; |
---|
| 393 | xParseSEIFrameFieldInfo ((SEIFrameFieldInfo&) *sei, payloadSize); |
---|
| 394 | break; |
---|
| 395 | #endif |
---|
[595] | 396 | #endif //SVC_EXTENSION |
---|
[313] | 397 | break; |
---|
| 398 | default: |
---|
| 399 | for (UInt i = 0; i < payloadSize; i++) |
---|
| 400 | { |
---|
| 401 | UInt seiByte; |
---|
| 402 | READ_CODE (8, seiByte, "unknown prefix SEI payload byte"); |
---|
| 403 | } |
---|
| 404 | printf ("Unknown prefix SEI message (payloadType = %d) was found!\n", payloadType); |
---|
| 405 | } |
---|
| 406 | } |
---|
| 407 | else |
---|
| 408 | { |
---|
| 409 | switch (payloadType) |
---|
| 410 | { |
---|
| 411 | case SEI::USER_DATA_UNREGISTERED: |
---|
| 412 | sei = new SEIuserDataUnregistered; |
---|
| 413 | xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize); |
---|
| 414 | break; |
---|
| 415 | case SEI::DECODED_PICTURE_HASH: |
---|
| 416 | sei = new SEIDecodedPictureHash; |
---|
| 417 | xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize); |
---|
| 418 | break; |
---|
| 419 | default: |
---|
| 420 | for (UInt i = 0; i < payloadSize; i++) |
---|
| 421 | { |
---|
| 422 | UInt seiByte; |
---|
| 423 | READ_CODE (8, seiByte, "unknown suffix SEI payload byte"); |
---|
| 424 | } |
---|
| 425 | printf ("Unknown suffix SEI message (payloadType = %d) was found!\n", payloadType); |
---|
| 426 | } |
---|
| 427 | } |
---|
| 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; |
---|
| 446 | READ_CODE (1, reservedPayloadExtensionData, "reserved_payload_extension_data"); |
---|
| 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; |
---|
| 461 | READ_FLAG (reservedPayloadExtensionData, "reserved_payload_extension_data"); |
---|
| 462 | } |
---|
| 463 | |
---|
| 464 | UInt dummy; |
---|
| 465 | READ_FLAG (dummy, "payload_bit_equal_to_one"); payloadBitsRemaining--; |
---|
| 466 | while (payloadBitsRemaining) |
---|
| 467 | { |
---|
| 468 | READ_FLAG (dummy, "payload_bit_equal_to_zero"); payloadBitsRemaining--; |
---|
| 469 | } |
---|
| 470 | } |
---|
| 471 | |
---|
| 472 | /* restore primary bitstream for sei_message */ |
---|
[442] | 473 | getBitstream()->deleteFifo(); |
---|
[313] | 474 | delete getBitstream(); |
---|
| 475 | setBitstream(bs); |
---|
| 476 | } |
---|
| 477 | |
---|
[644] | 478 | #if P0138_USE_ALT_CPB_PARAMS_FLAG |
---|
[313] | 479 | /** |
---|
[644] | 480 | * Check if SEI message contains payload extension |
---|
| 481 | */ |
---|
| 482 | Bool SEIReader::xPayloadExtensionPresent() |
---|
| 483 | { |
---|
| 484 | Int payloadBitsRemaining = getBitstream()->getNumBitsLeft(); |
---|
| 485 | Bool payloadExtensionPresent = false; |
---|
| 486 | |
---|
| 487 | if (payloadBitsRemaining > 8) |
---|
| 488 | { |
---|
| 489 | payloadExtensionPresent = true; |
---|
| 490 | } |
---|
| 491 | else |
---|
| 492 | { |
---|
| 493 | Int finalBits = getBitstream()->peekBits(payloadBitsRemaining); |
---|
| 494 | while (payloadBitsRemaining && (finalBits & 1) == 0) |
---|
| 495 | { |
---|
| 496 | payloadBitsRemaining--; |
---|
| 497 | finalBits >>= 1; |
---|
| 498 | } |
---|
| 499 | payloadBitsRemaining--; |
---|
| 500 | if (payloadBitsRemaining > 0) |
---|
| 501 | { |
---|
| 502 | payloadExtensionPresent = true; |
---|
| 503 | } |
---|
| 504 | } |
---|
| 505 | |
---|
| 506 | return payloadExtensionPresent; |
---|
| 507 | } |
---|
| 508 | #endif |
---|
| 509 | |
---|
| 510 | /** |
---|
[313] | 511 | * parse bitstream bs and unpack a user_data_unregistered SEI message |
---|
| 512 | * of payloasSize bytes into sei. |
---|
| 513 | */ |
---|
| 514 | Void SEIReader::xParseSEIuserDataUnregistered(SEIuserDataUnregistered &sei, UInt payloadSize) |
---|
| 515 | { |
---|
| 516 | assert(payloadSize >= 16); |
---|
| 517 | UInt val; |
---|
| 518 | |
---|
| 519 | for (UInt i = 0; i < 16; i++) |
---|
| 520 | { |
---|
| 521 | READ_CODE (8, val, "uuid_iso_iec_11578"); |
---|
| 522 | sei.uuid_iso_iec_11578[i] = val; |
---|
| 523 | } |
---|
| 524 | |
---|
| 525 | sei.userDataLength = payloadSize - 16; |
---|
| 526 | if (!sei.userDataLength) |
---|
| 527 | { |
---|
| 528 | sei.userData = 0; |
---|
| 529 | return; |
---|
| 530 | } |
---|
| 531 | |
---|
| 532 | sei.userData = new UChar[sei.userDataLength]; |
---|
| 533 | for (UInt i = 0; i < sei.userDataLength; i++) |
---|
| 534 | { |
---|
| 535 | READ_CODE (8, val, "user_data" ); |
---|
| 536 | sei.userData[i] = val; |
---|
| 537 | } |
---|
| 538 | } |
---|
| 539 | |
---|
| 540 | /** |
---|
| 541 | * parse bitstream bs and unpack a decoded picture hash SEI message |
---|
| 542 | * of payloadSize bytes into sei. |
---|
| 543 | */ |
---|
| 544 | Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt /*payloadSize*/) |
---|
| 545 | { |
---|
| 546 | UInt val; |
---|
| 547 | READ_CODE (8, val, "hash_type"); |
---|
| 548 | sei.method = static_cast<SEIDecodedPictureHash::Method>(val); |
---|
| 549 | for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++) |
---|
| 550 | { |
---|
| 551 | if(SEIDecodedPictureHash::MD5 == sei.method) |
---|
| 552 | { |
---|
| 553 | for (UInt i = 0; i < 16; i++) |
---|
| 554 | { |
---|
| 555 | READ_CODE(8, val, "picture_md5"); |
---|
| 556 | sei.digest[yuvIdx][i] = val; |
---|
| 557 | } |
---|
| 558 | } |
---|
| 559 | else if(SEIDecodedPictureHash::CRC == sei.method) |
---|
| 560 | { |
---|
| 561 | READ_CODE(16, val, "picture_crc"); |
---|
| 562 | sei.digest[yuvIdx][0] = val >> 8 & 0xFF; |
---|
| 563 | sei.digest[yuvIdx][1] = val & 0xFF; |
---|
| 564 | } |
---|
| 565 | else if(SEIDecodedPictureHash::CHECKSUM == sei.method) |
---|
| 566 | { |
---|
| 567 | READ_CODE(32, val, "picture_checksum"); |
---|
| 568 | sei.digest[yuvIdx][0] = (val>>24) & 0xff; |
---|
| 569 | sei.digest[yuvIdx][1] = (val>>16) & 0xff; |
---|
| 570 | sei.digest[yuvIdx][2] = (val>>8) & 0xff; |
---|
| 571 | sei.digest[yuvIdx][3] = val & 0xff; |
---|
| 572 | } |
---|
| 573 | } |
---|
| 574 | } |
---|
| 575 | Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt /*payloadSize*/) |
---|
| 576 | { |
---|
| 577 | UInt val; |
---|
[713] | 578 | READ_CODE(4, val, "active_video_parameter_set_id"); sei.activeVPSId = val; |
---|
| 579 | READ_FLAG( val, "self_contained_cvs_flag"); sei.m_selfContainedCvsFlag = val ? true : false; |
---|
| 580 | READ_FLAG( val, "no_parameter_set_update_flag"); sei.m_noParameterSetUpdateFlag = val ? true : false; |
---|
[313] | 581 | READ_UVLC( val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val; |
---|
| 582 | |
---|
[713] | 583 | sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1); |
---|
[313] | 584 | for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++) |
---|
| 585 | { |
---|
[713] | 586 | READ_UVLC(val, "active_seq_parameter_set_id"); sei.activeSeqParameterSetId[i] = val; |
---|
[313] | 587 | } |
---|
| 588 | |
---|
[713] | 589 | xParseByteAlign(); |
---|
[313] | 590 | } |
---|
| 591 | |
---|
| 592 | Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt /*payloadSize*/, TComSPS *sps) |
---|
| 593 | { |
---|
| 594 | UInt val; |
---|
| 595 | READ_UVLC(val, "decoding_unit_idx"); |
---|
| 596 | sei.m_decodingUnitIdx = val; |
---|
| 597 | |
---|
| 598 | TComVUI *vui = sps->getVuiParameters(); |
---|
| 599 | if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag()) |
---|
| 600 | { |
---|
| 601 | READ_CODE( ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay"); |
---|
| 602 | sei.m_duSptCpbRemovalDelay = val; |
---|
| 603 | } |
---|
| 604 | else |
---|
| 605 | { |
---|
| 606 | sei.m_duSptCpbRemovalDelay = 0; |
---|
| 607 | } |
---|
| 608 | READ_FLAG( val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = val ? true : false; |
---|
| 609 | if(sei.m_dpbOutputDuDelayPresentFlag) |
---|
| 610 | { |
---|
| 611 | READ_CODE(vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay"); |
---|
| 612 | sei.m_picSptDpbOutputDuDelay = val; |
---|
| 613 | } |
---|
| 614 | xParseByteAlign(); |
---|
| 615 | } |
---|
| 616 | |
---|
| 617 | Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt /*payloadSize*/, TComSPS *sps) |
---|
| 618 | { |
---|
| 619 | Int i, nalOrVcl; |
---|
| 620 | UInt code; |
---|
| 621 | |
---|
| 622 | TComVUI *pVUI = sps->getVuiParameters(); |
---|
| 623 | TComHRD *pHRD = pVUI->getHrdParameters(); |
---|
| 624 | |
---|
| 625 | READ_UVLC( code, "bp_seq_parameter_set_id" ); sei.m_bpSeqParameterSetId = code; |
---|
| 626 | if( !pHRD->getSubPicCpbParamsPresentFlag() ) |
---|
| 627 | { |
---|
[595] | 628 | READ_FLAG( code, "irap_cpb_params_present_flag" ); sei.m_rapCpbParamsPresentFlag = code; |
---|
[313] | 629 | } |
---|
[595] | 630 | if( sei.m_rapCpbParamsPresentFlag ) |
---|
| 631 | { |
---|
| 632 | READ_CODE( pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" ); sei.m_cpbDelayOffset = code; |
---|
| 633 | READ_CODE( pHRD->getDpbOutputDelayLengthMinus1() + 1, code, "dpb_delay_offset" ); sei.m_dpbDelayOffset = code; |
---|
| 634 | } |
---|
[313] | 635 | //read splicing flag and cpb_removal_delay_delta |
---|
| 636 | READ_FLAG( code, "concatenation_flag"); |
---|
| 637 | sei.m_concatenationFlag = code; |
---|
| 638 | READ_CODE( ( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" ); |
---|
| 639 | sei.m_auCpbRemovalDelayDelta = code + 1; |
---|
| 640 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
| 641 | { |
---|
| 642 | if( ( ( nalOrVcl == 0 ) && ( pHRD->getNalHrdParametersPresentFlag() ) ) || |
---|
| 643 | ( ( nalOrVcl == 1 ) && ( pHRD->getVclHrdParametersPresentFlag() ) ) ) |
---|
| 644 | { |
---|
| 645 | for( i = 0; i < ( pHRD->getCpbCntMinus1( 0 ) + 1 ); i ++ ) |
---|
| 646 | { |
---|
| 647 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay" ); |
---|
| 648 | sei.m_initialCpbRemovalDelay[i][nalOrVcl] = code; |
---|
| 649 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay_offset" ); |
---|
| 650 | sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl] = code; |
---|
| 651 | if( pHRD->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag ) |
---|
| 652 | { |
---|
| 653 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay" ); |
---|
| 654 | sei.m_initialAltCpbRemovalDelay[i][nalOrVcl] = code; |
---|
| 655 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay_offset" ); |
---|
| 656 | sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl] = code; |
---|
| 657 | } |
---|
| 658 | } |
---|
| 659 | } |
---|
| 660 | } |
---|
[644] | 661 | |
---|
| 662 | #if P0138_USE_ALT_CPB_PARAMS_FLAG |
---|
| 663 | sei.m_useAltCpbParamsFlag = false; |
---|
| 664 | sei.m_useAltCpbParamsFlagPresent = false; |
---|
| 665 | if (xPayloadExtensionPresent()) |
---|
| 666 | { |
---|
| 667 | READ_FLAG (code, "use_alt_cpb_params_flag"); |
---|
| 668 | sei.m_useAltCpbParamsFlag = code; |
---|
| 669 | sei.m_useAltCpbParamsFlagPresent = true; |
---|
| 670 | } |
---|
| 671 | #endif |
---|
| 672 | |
---|
[313] | 673 | xParseByteAlign(); |
---|
| 674 | } |
---|
| 675 | Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt /*payloadSize*/, TComSPS *sps) |
---|
| 676 | { |
---|
| 677 | Int i; |
---|
| 678 | UInt code; |
---|
| 679 | |
---|
| 680 | TComVUI *vui = sps->getVuiParameters(); |
---|
| 681 | TComHRD *hrd = vui->getHrdParameters(); |
---|
| 682 | |
---|
| 683 | if( vui->getFrameFieldInfoPresentFlag() ) |
---|
| 684 | { |
---|
| 685 | READ_CODE( 4, code, "pic_struct" ); sei.m_picStruct = code; |
---|
| 686 | READ_CODE( 2, code, "source_scan_type" ); sei.m_sourceScanType = code; |
---|
| 687 | READ_FLAG( code, "duplicate_flag" ); sei.m_duplicateFlag = ( code == 1 ? true : false ); |
---|
| 688 | } |
---|
| 689 | |
---|
| 690 | if( hrd->getCpbDpbDelaysPresentFlag()) |
---|
| 691 | { |
---|
| 692 | READ_CODE( ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" ); |
---|
| 693 | sei.m_auCpbRemovalDelay = code + 1; |
---|
| 694 | READ_CODE( ( hrd->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" ); |
---|
| 695 | sei.m_picDpbOutputDelay = code; |
---|
| 696 | |
---|
| 697 | if(hrd->getSubPicCpbParamsPresentFlag()) |
---|
| 698 | { |
---|
| 699 | READ_CODE(hrd->getDpbOutputDelayDuLengthMinus1()+1, code, "pic_dpb_output_du_delay" ); |
---|
| 700 | sei.m_picDpbOutputDuDelay = code; |
---|
| 701 | } |
---|
| 702 | if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() ) |
---|
| 703 | { |
---|
| 704 | READ_UVLC( code, "num_decoding_units_minus1"); |
---|
| 705 | sei.m_numDecodingUnitsMinus1 = code; |
---|
| 706 | READ_FLAG( code, "du_common_cpb_removal_delay_flag" ); |
---|
| 707 | sei.m_duCommonCpbRemovalDelayFlag = code; |
---|
| 708 | if( sei.m_duCommonCpbRemovalDelayFlag ) |
---|
| 709 | { |
---|
| 710 | READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_minus1" ); |
---|
| 711 | sei.m_duCommonCpbRemovalDelayMinus1 = code; |
---|
| 712 | } |
---|
| 713 | if( sei.m_numNalusInDuMinus1 != NULL ) |
---|
| 714 | { |
---|
| 715 | delete sei.m_numNalusInDuMinus1; |
---|
| 716 | } |
---|
| 717 | sei.m_numNalusInDuMinus1 = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ]; |
---|
| 718 | if( sei.m_duCpbRemovalDelayMinus1 != NULL ) |
---|
| 719 | { |
---|
| 720 | delete sei.m_duCpbRemovalDelayMinus1; |
---|
| 721 | } |
---|
| 722 | sei.m_duCpbRemovalDelayMinus1 = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ]; |
---|
| 723 | |
---|
| 724 | for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ ) |
---|
| 725 | { |
---|
| 726 | READ_UVLC( code, "num_nalus_in_du_minus1"); |
---|
| 727 | sei.m_numNalusInDuMinus1[ i ] = code; |
---|
| 728 | if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) ) |
---|
| 729 | { |
---|
| 730 | READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1" ); |
---|
| 731 | sei.m_duCpbRemovalDelayMinus1[ i ] = code; |
---|
| 732 | } |
---|
| 733 | } |
---|
| 734 | } |
---|
| 735 | } |
---|
| 736 | xParseByteAlign(); |
---|
| 737 | } |
---|
| 738 | Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt /*payloadSize*/) |
---|
| 739 | { |
---|
| 740 | Int iCode; |
---|
| 741 | UInt uiCode; |
---|
| 742 | READ_SVLC( iCode, "recovery_poc_cnt" ); sei.m_recoveryPocCnt = iCode; |
---|
| 743 | READ_FLAG( uiCode, "exact_matching_flag" ); sei.m_exactMatchingFlag = uiCode; |
---|
| 744 | READ_FLAG( uiCode, "broken_link_flag" ); sei.m_brokenLinkFlag = uiCode; |
---|
| 745 | xParseByteAlign(); |
---|
| 746 | } |
---|
| 747 | Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt /*payloadSize*/) |
---|
| 748 | { |
---|
| 749 | UInt val; |
---|
| 750 | READ_UVLC( val, "frame_packing_arrangement_id" ); sei.m_arrangementId = val; |
---|
| 751 | READ_FLAG( val, "frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; |
---|
| 752 | |
---|
| 753 | if ( !sei.m_arrangementCancelFlag ) |
---|
| 754 | { |
---|
| 755 | READ_CODE( 7, val, "frame_packing_arrangement_type" ); sei.m_arrangementType = val; |
---|
| 756 | assert((sei.m_arrangementType > 2) && (sei.m_arrangementType < 6) ); |
---|
| 757 | READ_FLAG( val, "quincunx_sampling_flag" ); sei.m_quincunxSamplingFlag = val; |
---|
| 758 | |
---|
| 759 | READ_CODE( 6, val, "content_interpretation_type" ); sei.m_contentInterpretationType = val; |
---|
| 760 | READ_FLAG( val, "spatial_flipping_flag" ); sei.m_spatialFlippingFlag = val; |
---|
| 761 | READ_FLAG( val, "frame0_flipped_flag" ); sei.m_frame0FlippedFlag = val; |
---|
| 762 | READ_FLAG( val, "field_views_flag" ); sei.m_fieldViewsFlag = val; |
---|
| 763 | READ_FLAG( val, "current_frame_is_frame0_flag" ); sei.m_currentFrameIsFrame0Flag = val; |
---|
| 764 | READ_FLAG( val, "frame0_self_contained_flag" ); sei.m_frame0SelfContainedFlag = val; |
---|
| 765 | READ_FLAG( val, "frame1_self_contained_flag" ); sei.m_frame1SelfContainedFlag = val; |
---|
| 766 | |
---|
| 767 | if ( sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5) |
---|
| 768 | { |
---|
| 769 | READ_CODE( 4, val, "frame0_grid_position_x" ); sei.m_frame0GridPositionX = val; |
---|
| 770 | READ_CODE( 4, val, "frame0_grid_position_y" ); sei.m_frame0GridPositionY = val; |
---|
| 771 | READ_CODE( 4, val, "frame1_grid_position_x" ); sei.m_frame1GridPositionX = val; |
---|
| 772 | READ_CODE( 4, val, "frame1_grid_position_y" ); sei.m_frame1GridPositionY = val; |
---|
| 773 | } |
---|
| 774 | |
---|
| 775 | READ_CODE( 8, val, "frame_packing_arrangement_reserved_byte" ); sei.m_arrangementReservedByte = val; |
---|
| 776 | READ_FLAG( val, "frame_packing_arrangement_persistence_flag" ); sei.m_arrangementPersistenceFlag = val ? true : false; |
---|
| 777 | } |
---|
| 778 | READ_FLAG( val, "upsampled_aspect_ratio" ); sei.m_upsampledAspectRatio = val; |
---|
| 779 | |
---|
| 780 | xParseByteAlign(); |
---|
| 781 | } |
---|
| 782 | |
---|
| 783 | Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt /*payloadSize*/) |
---|
| 784 | { |
---|
| 785 | UInt val; |
---|
| 786 | READ_FLAG( val, "display_orientation_cancel_flag" ); sei.cancelFlag = val; |
---|
| 787 | if( !sei.cancelFlag ) |
---|
| 788 | { |
---|
| 789 | READ_FLAG( val, "hor_flip" ); sei.horFlip = val; |
---|
| 790 | READ_FLAG( val, "ver_flip" ); sei.verFlip = val; |
---|
| 791 | READ_CODE( 16, val, "anticlockwise_rotation" ); sei.anticlockwiseRotation = val; |
---|
| 792 | READ_FLAG( val, "display_orientation_persistence_flag" ); sei.persistenceFlag = val; |
---|
| 793 | } |
---|
| 794 | xParseByteAlign(); |
---|
| 795 | } |
---|
| 796 | |
---|
| 797 | Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt /*payloadSize*/) |
---|
| 798 | { |
---|
| 799 | UInt val; |
---|
| 800 | READ_CODE ( 8, val, "tl0_idx" ); sei.tl0Idx = val; |
---|
| 801 | READ_CODE ( 8, val, "rap_idx" ); sei.rapIdx = val; |
---|
| 802 | xParseByteAlign(); |
---|
| 803 | } |
---|
| 804 | |
---|
| 805 | Void SEIReader::xParseSEIGradualDecodingRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt /*payloadSize*/) |
---|
| 806 | { |
---|
| 807 | UInt val; |
---|
| 808 | READ_FLAG( val, "gdr_foreground_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0; |
---|
| 809 | xParseByteAlign(); |
---|
| 810 | } |
---|
| 811 | |
---|
| 812 | Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt /*payloadSize*/) |
---|
| 813 | { |
---|
| 814 | Int i; |
---|
| 815 | UInt val; |
---|
| 816 | READ_UVLC( val, "tone_map_id" ); sei.m_toneMapId = val; |
---|
| 817 | READ_FLAG( val, "tone_map_cancel_flag" ); sei.m_toneMapCancelFlag = val; |
---|
| 818 | |
---|
| 819 | if ( !sei.m_toneMapCancelFlag ) |
---|
| 820 | { |
---|
| 821 | READ_FLAG( val, "tone_map_persistence_flag" ); sei.m_toneMapPersistenceFlag = val; |
---|
| 822 | READ_CODE( 8, val, "coded_data_bit_depth" ); sei.m_codedDataBitDepth = val; |
---|
| 823 | READ_CODE( 8, val, "target_bit_depth" ); sei.m_targetBitDepth = val; |
---|
| 824 | READ_UVLC( val, "model_id" ); sei.m_modelId = val; |
---|
| 825 | switch(sei.m_modelId) |
---|
| 826 | { |
---|
| 827 | case 0: |
---|
| 828 | { |
---|
| 829 | READ_CODE( 32, val, "min_value" ); sei.m_minValue = val; |
---|
| 830 | READ_CODE( 32, val, "max_value" ); sei.m_maxValue = val; |
---|
| 831 | break; |
---|
| 832 | } |
---|
| 833 | case 1: |
---|
| 834 | { |
---|
| 835 | READ_CODE( 32, val, "sigmoid_midpoint" ); sei.m_sigmoidMidpoint = val; |
---|
| 836 | READ_CODE( 32, val, "sigmoid_width" ); sei.m_sigmoidWidth = val; |
---|
| 837 | break; |
---|
| 838 | } |
---|
| 839 | case 2: |
---|
| 840 | { |
---|
| 841 | UInt num = 1u << sei.m_targetBitDepth; |
---|
| 842 | sei.m_startOfCodedInterval.resize(num+1); |
---|
| 843 | for(i = 0; i < num; i++) |
---|
| 844 | { |
---|
| 845 | READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval" ); |
---|
| 846 | sei.m_startOfCodedInterval[i] = val; |
---|
| 847 | } |
---|
| 848 | sei.m_startOfCodedInterval[num] = 1u << sei.m_codedDataBitDepth; |
---|
| 849 | break; |
---|
| 850 | } |
---|
| 851 | case 3: |
---|
| 852 | { |
---|
| 853 | READ_CODE( 16, val, "num_pivots" ); sei.m_numPivots = val; |
---|
| 854 | sei.m_codedPivotValue.resize(sei.m_numPivots); |
---|
| 855 | sei.m_targetPivotValue.resize(sei.m_numPivots); |
---|
| 856 | for(i = 0; i < sei.m_numPivots; i++ ) |
---|
| 857 | { |
---|
| 858 | READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value" ); |
---|
| 859 | sei.m_codedPivotValue[i] = val; |
---|
| 860 | READ_CODE( ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3), val, "target_pivot_value" ); |
---|
| 861 | sei.m_targetPivotValue[i] = val; |
---|
| 862 | } |
---|
| 863 | break; |
---|
| 864 | } |
---|
| 865 | case 4: |
---|
| 866 | { |
---|
[713] | 867 | READ_CODE( 8, val, "camera_iso_speed_idc" ); sei.m_cameraIsoSpeedIdc = val; |
---|
| 868 | if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO |
---|
[313] | 869 | { |
---|
| 870 | READ_CODE( 32, val, "camera_iso_speed_value" ); sei.m_cameraIsoSpeedValue = val; |
---|
| 871 | } |
---|
[713] | 872 | READ_CODE( 8, val, "exposure_index_idc" ); sei.m_exposureIndexIdc = val; |
---|
| 873 | if( sei.m_exposureIndexIdc == 255) //Extended_ISO |
---|
| 874 | { |
---|
| 875 | READ_CODE( 32, val, "exposure_index_value" ); sei.m_exposureIndexValue = val; |
---|
| 876 | } |
---|
[313] | 877 | READ_FLAG( val, "exposure_compensation_value_sign_flag" ); sei.m_exposureCompensationValueSignFlag = val; |
---|
| 878 | READ_CODE( 16, val, "exposure_compensation_value_numerator" ); sei.m_exposureCompensationValueNumerator = val; |
---|
| 879 | READ_CODE( 16, val, "exposure_compensation_value_denom_idc" ); sei.m_exposureCompensationValueDenomIdc = val; |
---|
| 880 | READ_CODE( 32, val, "ref_screen_luminance_white" ); sei.m_refScreenLuminanceWhite = val; |
---|
| 881 | READ_CODE( 32, val, "extended_range_white_level" ); sei.m_extendedRangeWhiteLevel = val; |
---|
| 882 | READ_CODE( 16, val, "nominal_black_level_luma_code_value" ); sei.m_nominalBlackLevelLumaCodeValue = val; |
---|
| 883 | READ_CODE( 16, val, "nominal_white_level_luma_code_value" ); sei.m_nominalWhiteLevelLumaCodeValue= val; |
---|
| 884 | READ_CODE( 16, val, "extended_white_level_luma_code_value" ); sei.m_extendedWhiteLevelLumaCodeValue = val; |
---|
| 885 | break; |
---|
| 886 | } |
---|
| 887 | default: |
---|
| 888 | { |
---|
| 889 | assert(!"Undefined SEIToneMapModelId"); |
---|
| 890 | break; |
---|
| 891 | } |
---|
| 892 | }//switch model id |
---|
| 893 | }// if(!sei.m_toneMapCancelFlag) |
---|
| 894 | |
---|
| 895 | xParseByteAlign(); |
---|
| 896 | } |
---|
| 897 | |
---|
[815] | 898 | #if P0050_KNEE_FUNCTION_SEI |
---|
| 899 | Void SEIReader::xParseSEIKneeFunctionInfo(SEIKneeFunctionInfo& sei, UInt /*payloadSize*/){ |
---|
| 900 | Int i; |
---|
| 901 | UInt val; |
---|
| 902 | READ_UVLC( val, "knee_function_id" ); sei.m_kneeId = val; |
---|
| 903 | READ_FLAG( val, "knee_function_cancel_flag" ); sei.m_kneeCancelFlag = val; |
---|
| 904 | if ( !sei.m_kneeCancelFlag ) |
---|
| 905 | { |
---|
| 906 | READ_FLAG( val, "knee_function_persistence_flag" ); sei.m_kneePersistenceFlag = val; |
---|
| 907 | READ_FLAG( val, "mapping_flag" ); sei.m_kneeMappingFlag = val; |
---|
| 908 | READ_CODE( 32, val, "input_d_range" ); sei.m_kneeInputDrange = val; |
---|
| 909 | READ_CODE( 32, val, "input_disp_luminance" ); sei.m_kneeInputDispLuminance = val; |
---|
| 910 | READ_CODE( 32, val, "output_d_range" ); sei.m_kneeOutputDrange = val; |
---|
| 911 | READ_CODE( 32, val, "output_disp_luminance" ); sei.m_kneeOutputDispLuminance = val; |
---|
| 912 | READ_UVLC( val, "num_knee_points_minus1" ); sei.m_kneeNumKneePointsMinus1 = val; |
---|
| 913 | assert( sei.m_kneeNumKneePointsMinus1 > 0 ); |
---|
| 914 | sei.m_kneeInputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1); |
---|
| 915 | sei.m_kneeOutputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1); |
---|
| 916 | for(i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ ) |
---|
| 917 | { |
---|
| 918 | READ_CODE( 10, val, "input_knee_point" ); sei.m_kneeInputKneePoint[i] = val; |
---|
| 919 | READ_CODE( 10, val, "output_knee_point" ); sei.m_kneeOutputKneePoint[i] = val; |
---|
| 920 | } |
---|
| 921 | } |
---|
| 922 | } |
---|
| 923 | #endif |
---|
| 924 | |
---|
[713] | 925 | #if Q0074_SEI_COLOR_MAPPING |
---|
| 926 | Void SEIReader::xParseSEIColorMappingInfo(SEIColorMappingInfo& sei, UInt /*payloadSize*/) |
---|
| 927 | { |
---|
| 928 | UInt uiVal; |
---|
| 929 | Int iVal; |
---|
| 930 | |
---|
| 931 | READ_UVLC( uiVal, "colour_map_id" ); sei.m_colorMapId = uiVal; |
---|
| 932 | READ_FLAG( uiVal, "colour_map_cancel_flag" ); sei.m_colorMapCancelFlag = uiVal; |
---|
| 933 | if( !sei.m_colorMapCancelFlag ) |
---|
| 934 | { |
---|
| 935 | READ_FLAG( uiVal, "colour_map_persistence_flag" ); sei.m_colorMapPersistenceFlag = uiVal; |
---|
| 936 | READ_FLAG( uiVal, "colour_map_video_signal_type_present_flag" ); sei.m_colorMap_video_signal_type_present_flag = uiVal; |
---|
| 937 | if ( sei.m_colorMap_video_signal_type_present_flag ) { |
---|
| 938 | READ_FLAG( uiVal, "colour_map_video_full_range_flag" ); sei.m_colorMap_video_full_range_flag = uiVal; |
---|
| 939 | READ_CODE( 8, uiVal, "colour_map_primaries" ); sei.m_colorMap_primaries = uiVal; |
---|
| 940 | READ_CODE( 8, uiVal, "colour_map_transfer_characteristics" ); sei.m_colorMap_transfer_characteristics = uiVal; |
---|
| 941 | READ_CODE( 8, uiVal, "colour_map_matrix_coeffs" ); sei.m_colorMap_matrix_coeffs = uiVal; |
---|
| 942 | } |
---|
| 943 | } |
---|
| 944 | |
---|
| 945 | READ_CODE( 5, uiVal, "colour_map_coded_data_bit_depth" ); sei.m_colour_map_coded_data_bit_depth = uiVal; |
---|
| 946 | READ_CODE( 5, uiVal, "colour_map_target_bit_depth" ); sei.m_colour_map_target_bit_depth = uiVal; |
---|
| 947 | READ_UVLC( uiVal, "colour_map_model_id" ); sei.m_colorMapModelId = uiVal; |
---|
| 948 | |
---|
| 949 | assert( sei.m_colorMapModelId == 0 ); |
---|
| 950 | |
---|
| 951 | for( Int i=0 ; i<3 ; i++ ) |
---|
| 952 | { |
---|
| 953 | READ_CODE( 8, uiVal, "num_input_pivots_minus1[i]" ); sei.m_num_input_pivots[i] = (uiVal==0) ? 2 : (uiVal + 1) ; |
---|
| 954 | sei.m_coded_input_pivot_value[i] = new Int[ sei.m_num_input_pivots[i] ]; |
---|
| 955 | sei.m_target_input_pivot_value[i] = new Int[ sei.m_num_input_pivots[i] ]; |
---|
| 956 | if( uiVal > 0 ) |
---|
| 957 | { |
---|
| 958 | for ( Int j=0 ; j<sei.m_num_input_pivots[i] ; j++ ) |
---|
| 959 | { |
---|
| 960 | 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; |
---|
| 961 | 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; |
---|
| 962 | } |
---|
| 963 | } |
---|
| 964 | else |
---|
| 965 | { |
---|
| 966 | sei.m_coded_input_pivot_value[i][0] = 0; |
---|
| 967 | sei.m_target_input_pivot_value[i][0] = 0; |
---|
| 968 | sei.m_coded_input_pivot_value[i][1] = (1 << sei.m_colour_map_coded_data_bit_depth) - 1 ; |
---|
| 969 | sei.m_target_input_pivot_value[i][1] = (1 << sei.m_colour_map_target_bit_depth) - 1 ; |
---|
| 970 | } |
---|
| 971 | } |
---|
| 972 | |
---|
| 973 | READ_FLAG( uiVal, "matrix_flag" ); sei.m_matrix_flag = uiVal; |
---|
| 974 | if( sei.m_matrix_flag ) |
---|
| 975 | { |
---|
| 976 | READ_CODE( 4, uiVal, "log2_matrix_denom" ); sei.m_log2_matrix_denom = uiVal; |
---|
| 977 | for ( Int i=0 ; i<3 ; i++ ) |
---|
| 978 | { |
---|
| 979 | for ( Int j=0 ; j<3 ; j++ ) |
---|
| 980 | { |
---|
| 981 | READ_SVLC( iVal, "matrix_coef[i][j]" ); sei.m_matrix_coef[i][j] = iVal; |
---|
| 982 | } |
---|
| 983 | } |
---|
| 984 | } |
---|
| 985 | |
---|
| 986 | for ( Int i=0 ; i<3 ; i++ ) |
---|
| 987 | { |
---|
| 988 | READ_CODE( 8, uiVal, "num_output_pivots_minus1[i]" ); sei.m_num_output_pivots[i] = (uiVal==0) ? 2 : (uiVal + 1) ; |
---|
| 989 | sei.m_coded_output_pivot_value[i] = new Int[ sei.m_num_output_pivots[i] ]; |
---|
| 990 | sei.m_target_output_pivot_value[i] = new Int[ sei.m_num_output_pivots[i] ]; |
---|
| 991 | if( uiVal > 0 ) |
---|
| 992 | { |
---|
| 993 | for ( Int j=0 ; j<sei.m_num_output_pivots[i] ; j++ ) |
---|
| 994 | { |
---|
| 995 | 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; |
---|
| 996 | 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; |
---|
| 997 | } |
---|
| 998 | } |
---|
| 999 | else |
---|
| 1000 | { |
---|
| 1001 | sei.m_coded_output_pivot_value[i][0] = 0; |
---|
| 1002 | sei.m_target_output_pivot_value[i][0] = 0; |
---|
| 1003 | sei.m_coded_output_pivot_value[i][1] = (1 << sei.m_colour_map_coded_data_bit_depth) - 1 ; |
---|
| 1004 | sei.m_target_output_pivot_value[i][1] = (1 << sei.m_colour_map_target_bit_depth) - 1 ; |
---|
| 1005 | } |
---|
| 1006 | } |
---|
| 1007 | |
---|
| 1008 | xParseByteAlign(); |
---|
| 1009 | } |
---|
| 1010 | #endif |
---|
| 1011 | |
---|
[313] | 1012 | Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize) |
---|
| 1013 | { |
---|
| 1014 | Int iCode; |
---|
| 1015 | UInt uiCode; |
---|
| 1016 | |
---|
| 1017 | READ_UVLC( uiCode, "sop_seq_parameter_set_id" ); sei.m_sopSeqParameterSetId = uiCode; |
---|
| 1018 | READ_UVLC( uiCode, "num_pics_in_sop_minus1" ); sei.m_numPicsInSopMinus1 = uiCode; |
---|
| 1019 | for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++) |
---|
| 1020 | { |
---|
| 1021 | READ_CODE( 6, uiCode, "sop_desc_vcl_nalu_type" ); sei.m_sopDescVclNaluType[i] = uiCode; |
---|
| 1022 | READ_CODE( 3, sei.m_sopDescTemporalId[i], "sop_desc_temporal_id" ); sei.m_sopDescTemporalId[i] = uiCode; |
---|
| 1023 | if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP) |
---|
| 1024 | { |
---|
| 1025 | READ_UVLC( sei.m_sopDescStRpsIdx[i], "sop_desc_st_rps_idx" ); sei.m_sopDescStRpsIdx[i] = uiCode; |
---|
| 1026 | } |
---|
| 1027 | if (i > 0) |
---|
| 1028 | { |
---|
| 1029 | READ_SVLC( iCode, "sop_desc_poc_delta" ); sei.m_sopDescPocDelta[i] = iCode; |
---|
| 1030 | } |
---|
| 1031 | } |
---|
| 1032 | |
---|
| 1033 | xParseByteAlign(); |
---|
| 1034 | } |
---|
| 1035 | |
---|
[815] | 1036 | #if Q0189_TMVP_CONSTRAINTS |
---|
| 1037 | Void SEIReader::xParseSEITMVPConstraints (SEITMVPConstrains& sei, UInt payloadSize) |
---|
| 1038 | { |
---|
| 1039 | UInt uiCode; |
---|
| 1040 | READ_UVLC( uiCode, "prev_pics_not_used_flag" ); sei.prev_pics_not_used_flag = uiCode; |
---|
| 1041 | READ_UVLC( uiCode, "no_intra_layer_col_pic_flag" ); sei.no_intra_layer_col_pic_flag = uiCode; |
---|
| 1042 | xParseByteAlign(); |
---|
| 1043 | } |
---|
| 1044 | #endif |
---|
| 1045 | |
---|
| 1046 | #if Q0247_FRAME_FIELD_INFO |
---|
| 1047 | Void SEIReader::xParseSEIFrameFieldInfo (SEIFrameFieldInfo& sei, UInt payloadSize) |
---|
| 1048 | { |
---|
| 1049 | UInt code; |
---|
| 1050 | READ_CODE( 4, code, "ffinfo_pic_struct" ); sei.m_ffinfo_picStruct = code; |
---|
| 1051 | READ_CODE( 2, code, "ffinfo_source_scan_type" ); sei.m_ffinfo_sourceScanType = code; |
---|
| 1052 | READ_FLAG( code, "ffinfo_duplicate_flag" ); sei.m_ffinfo_duplicateFlag = ( code == 1 ? true : false ); |
---|
| 1053 | xParseByteAlign(); |
---|
| 1054 | } |
---|
| 1055 | #endif |
---|
| 1056 | |
---|
[588] | 1057 | #if LAYERS_NOT_PRESENT_SEI |
---|
[313] | 1058 | Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComVPS *vps, TComSPS *sps) |
---|
| 1059 | #else |
---|
| 1060 | Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComSPS *sps) |
---|
| 1061 | #endif |
---|
| 1062 | { |
---|
| 1063 | UInt uiCode; |
---|
| 1064 | SEIMessages seis; |
---|
| 1065 | |
---|
| 1066 | READ_FLAG( uiCode, "bitstream_subset_flag" ); sei.m_bitStreamSubsetFlag = uiCode; |
---|
| 1067 | READ_FLAG( uiCode, "nesting_op_flag" ); sei.m_nestingOpFlag = uiCode; |
---|
| 1068 | if (sei.m_nestingOpFlag) |
---|
| 1069 | { |
---|
| 1070 | READ_FLAG( uiCode, "default_op_flag" ); sei.m_defaultOpFlag = uiCode; |
---|
| 1071 | READ_UVLC( uiCode, "nesting_num_ops_minus1" ); sei.m_nestingNumOpsMinus1 = uiCode; |
---|
| 1072 | for (UInt i = sei.m_defaultOpFlag; i <= sei.m_nestingNumOpsMinus1; i++) |
---|
| 1073 | { |
---|
| 1074 | READ_CODE( 3, uiCode, "nesting_max_temporal_id_plus1" ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode; |
---|
| 1075 | READ_UVLC( uiCode, "nesting_op_idx" ); sei.m_nestingOpIdx[i] = uiCode; |
---|
| 1076 | } |
---|
| 1077 | } |
---|
| 1078 | else |
---|
| 1079 | { |
---|
| 1080 | READ_FLAG( uiCode, "all_layers_flag" ); sei.m_allLayersFlag = uiCode; |
---|
| 1081 | if (!sei.m_allLayersFlag) |
---|
| 1082 | { |
---|
| 1083 | READ_CODE( 3, uiCode, "nesting_no_op_max_temporal_id_plus1" ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode; |
---|
| 1084 | READ_UVLC( uiCode, "nesting_num_layers_minus1" ); sei.m_nestingNumLayersMinus1 = uiCode; |
---|
| 1085 | for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++) |
---|
| 1086 | { |
---|
| 1087 | READ_CODE( 6, uiCode, "nesting_layer_id" ); sei.m_nestingLayerId[i] = uiCode; |
---|
| 1088 | } |
---|
| 1089 | } |
---|
| 1090 | } |
---|
| 1091 | |
---|
| 1092 | // byte alignment |
---|
| 1093 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
| 1094 | { |
---|
| 1095 | UInt code; |
---|
| 1096 | READ_FLAG( code, "nesting_zero_bit" ); |
---|
| 1097 | } |
---|
| 1098 | |
---|
| 1099 | sei.m_callerOwnsSEIs = false; |
---|
| 1100 | |
---|
| 1101 | // read nested SEI messages |
---|
| 1102 | do { |
---|
[644] | 1103 | #if O0164_MULTI_LAYER_HRD |
---|
[588] | 1104 | #if LAYERS_NOT_PRESENT_SEI |
---|
[644] | 1105 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, &sei); |
---|
| 1106 | #else |
---|
| 1107 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, &sei); |
---|
| 1108 | #endif |
---|
| 1109 | #else |
---|
| 1110 | #if LAYERS_NOT_PRESENT_SEI |
---|
[313] | 1111 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps); |
---|
| 1112 | #else |
---|
| 1113 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps); |
---|
| 1114 | #endif |
---|
[644] | 1115 | #endif |
---|
[313] | 1116 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
---|
| 1117 | |
---|
| 1118 | } |
---|
| 1119 | |
---|
| 1120 | Void SEIReader::xParseByteAlign() |
---|
| 1121 | { |
---|
| 1122 | UInt code; |
---|
| 1123 | if( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
| 1124 | { |
---|
| 1125 | READ_FLAG( code, "bit_equal_to_one" ); assert( code == 1 ); |
---|
| 1126 | } |
---|
| 1127 | while( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
| 1128 | { |
---|
| 1129 | READ_FLAG( code, "bit_equal_to_zero" ); assert( code == 0 ); |
---|
| 1130 | } |
---|
| 1131 | } |
---|
[595] | 1132 | |
---|
| 1133 | #if SVC_EXTENSION |
---|
| 1134 | #if LAYERS_NOT_PRESENT_SEI |
---|
| 1135 | Void SEIReader::xParseSEILayersNotPresent(SEILayersNotPresent &sei, UInt payloadSize, TComVPS *vps) |
---|
| 1136 | { |
---|
| 1137 | UInt uiCode; |
---|
| 1138 | UInt i = 0; |
---|
| 1139 | |
---|
| 1140 | READ_UVLC( uiCode, "lp_sei_active_vps_id" ); sei.m_activeVpsId = uiCode; |
---|
| 1141 | assert(vps->getVPSId() == sei.m_activeVpsId); |
---|
| 1142 | sei.m_vpsMaxLayers = vps->getMaxLayers(); |
---|
| 1143 | for (; i < sei.m_vpsMaxLayers; i++) |
---|
| 1144 | { |
---|
| 1145 | READ_FLAG( uiCode, "layer_not_present_flag" ); sei.m_layerNotPresentFlag[i] = uiCode ? true : false; |
---|
| 1146 | } |
---|
| 1147 | for (; i < MAX_LAYERS; i++) |
---|
| 1148 | { |
---|
| 1149 | sei.m_layerNotPresentFlag[i] = false; |
---|
| 1150 | } |
---|
| 1151 | xParseByteAlign(); |
---|
| 1152 | } |
---|
| 1153 | #endif |
---|
| 1154 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
| 1155 | Void SEIReader::xParseSEIInterLayerConstrainedTileSets (SEIInterLayerConstrainedTileSets &sei, UInt payloadSize) |
---|
| 1156 | { |
---|
| 1157 | UInt uiCode; |
---|
| 1158 | |
---|
| 1159 | READ_FLAG( uiCode, "il_all_tiles_exact_sample_value_match_flag" ); sei.m_ilAllTilesExactSampleValueMatchFlag = uiCode; |
---|
| 1160 | READ_FLAG( uiCode, "il_one_tile_per_tile_set_flag" ); sei.m_ilOneTilePerTileSetFlag = uiCode; |
---|
| 1161 | if( !sei.m_ilOneTilePerTileSetFlag ) |
---|
| 1162 | { |
---|
| 1163 | READ_UVLC( uiCode, "il_num_sets_in_message_minus1" ); sei.m_ilNumSetsInMessageMinus1 = uiCode; |
---|
| 1164 | if( sei.m_ilNumSetsInMessageMinus1 ) |
---|
| 1165 | { |
---|
| 1166 | READ_FLAG( uiCode, "skipped_tile_set_present_flag" ); sei.m_skippedTileSetPresentFlag = uiCode; |
---|
| 1167 | } |
---|
| 1168 | else |
---|
| 1169 | { |
---|
| 1170 | sei.m_skippedTileSetPresentFlag = false; |
---|
| 1171 | } |
---|
| 1172 | UInt numSignificantSets = sei.m_ilNumSetsInMessageMinus1 - (sei.m_skippedTileSetPresentFlag ? 1 : 0) + 1; |
---|
| 1173 | for( UInt i = 0; i < numSignificantSets; i++ ) |
---|
| 1174 | { |
---|
| 1175 | READ_UVLC( uiCode, "ilcts_id" ); sei.m_ilctsId[i] = uiCode; |
---|
| 1176 | READ_UVLC( uiCode, "il_num_tile_rects_in_set_minus1" ) ;sei.m_ilNumTileRectsInSetMinus1[i] = uiCode; |
---|
| 1177 | for( UInt j = 0; j <= sei.m_ilNumTileRectsInSetMinus1[i]; j++ ) |
---|
| 1178 | { |
---|
| 1179 | READ_UVLC( uiCode, "il_top_left_tile_index" ); sei.m_ilTopLeftTileIndex[i][j] = uiCode; |
---|
| 1180 | READ_UVLC( uiCode, "il_bottom_right_tile_index" ); sei.m_ilBottomRightTileIndex[i][j] = uiCode; |
---|
| 1181 | } |
---|
| 1182 | READ_CODE( 2, uiCode, "ilc_idc" ); sei.m_ilcIdc[i] = uiCode; |
---|
| 1183 | if( sei.m_ilAllTilesExactSampleValueMatchFlag ) |
---|
| 1184 | { |
---|
| 1185 | READ_FLAG( uiCode, "il_exact_sample_value_match_flag" ); sei.m_ilExactSampleValueMatchFlag[i] = uiCode; |
---|
| 1186 | } |
---|
| 1187 | } |
---|
| 1188 | } |
---|
| 1189 | else |
---|
| 1190 | { |
---|
| 1191 | READ_CODE( 2, uiCode, "all_tiles_ilc_idc" ); sei.m_allTilesIlcIdc = uiCode; |
---|
| 1192 | } |
---|
| 1193 | |
---|
| 1194 | xParseByteAlign(); |
---|
| 1195 | } |
---|
| 1196 | #endif |
---|
| 1197 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
| 1198 | Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei) |
---|
| 1199 | { |
---|
| 1200 | UInt uiCode; |
---|
| 1201 | READ_CODE( 4, uiCode, "active_vps_id" ); sei.m_activeVpsId = uiCode; |
---|
| 1202 | READ_UVLC( uiCode, "num_additional_sub_streams_minus1" ); sei.m_numAdditionalSubStreams = uiCode + 1; |
---|
| 1203 | |
---|
| 1204 | for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ ) |
---|
| 1205 | { |
---|
| 1206 | READ_CODE( 2, uiCode, "sub_bitstream_mode[i]" ); sei.m_subBitstreamMode[i] = uiCode; |
---|
| 1207 | READ_UVLC( uiCode, "output_layer_set_idx_to_vps[i]" ); sei.m_outputLayerSetIdxToVps[i] = uiCode; |
---|
| 1208 | READ_CODE( 3, uiCode, "highest_sub_layer_id[i]" ); sei.m_highestSublayerId[i] = uiCode; |
---|
| 1209 | READ_CODE( 16, uiCode, "avg_bit_rate[i]" ); sei.m_avgBitRate[i] = uiCode; |
---|
| 1210 | READ_CODE( 16, uiCode, "max_bit_rate[i]" ); sei.m_maxBitRate[i] = uiCode; |
---|
| 1211 | } |
---|
| 1212 | xParseByteAlign(); |
---|
| 1213 | } |
---|
| 1214 | #endif |
---|
[644] | 1215 | |
---|
| 1216 | #if O0164_MULTI_LAYER_HRD |
---|
| 1217 | #if LAYERS_NOT_PRESENT_SEI |
---|
| 1218 | Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei) |
---|
| 1219 | #else |
---|
| 1220 | Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, TComSPS *sps, const SEIScalableNesting &nestingSei) |
---|
| 1221 | #endif |
---|
| 1222 | { |
---|
| 1223 | UInt uiCode; |
---|
| 1224 | READ_UVLC( uiCode, "bsp_idx" ); sei.m_bspIdx = uiCode; |
---|
| 1225 | |
---|
| 1226 | // byte alignment |
---|
| 1227 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
| 1228 | { |
---|
| 1229 | UInt code; |
---|
| 1230 | READ_FLAG( code, "bsp_nesting_zero_bit" ); |
---|
| 1231 | } |
---|
| 1232 | |
---|
| 1233 | sei.m_callerOwnsSEIs = false; |
---|
| 1234 | |
---|
| 1235 | // read nested SEI messages |
---|
[847] | 1236 | #if NESTING_SEI_EXTENSIBILITY |
---|
| 1237 | Int numSeiMessages = 0; |
---|
| 1238 | READ_UVLC( uiCode, "num_seis_in_bsp_minus1" ); assert( uiCode <= MAX_SEIS_IN_BSP_NESTING ); |
---|
| 1239 | numSeiMessages = uiCode; |
---|
| 1240 | for(Int i = 0; i < numSeiMessages; i++) |
---|
| 1241 | { |
---|
| 1242 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, &nestingSei, &sei); |
---|
| 1243 | } |
---|
| 1244 | #else |
---|
[644] | 1245 | do { |
---|
| 1246 | #if LAYERS_NOT_PRESENT_SEI |
---|
| 1247 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, &nestingSei, &sei); |
---|
| 1248 | #else |
---|
| 1249 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, &nestingSei); |
---|
| 1250 | #endif |
---|
| 1251 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
---|
[847] | 1252 | #endif |
---|
[644] | 1253 | } |
---|
| 1254 | |
---|
| 1255 | Void SEIReader::xParseSEIBspInitialArrivalTime(SEIBspInitialArrivalTime &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei) |
---|
| 1256 | { |
---|
| 1257 | assert(vps->getVpsVuiPresentFlag()); |
---|
| 1258 | |
---|
| 1259 | UInt schedCombCnt = vps->getNumBspSchedCombinations(nestingSei.m_nestingOpIdx[0]); |
---|
| 1260 | UInt len; |
---|
| 1261 | UInt hrdIdx; |
---|
| 1262 | UInt uiCode; |
---|
| 1263 | |
---|
| 1264 | if (schedCombCnt > 0) |
---|
| 1265 | { |
---|
| 1266 | hrdIdx = vps->getBspCombHrdIdx(nestingSei.m_nestingOpIdx[0], 0, bspNestingSei.m_bspIdx); |
---|
| 1267 | } |
---|
| 1268 | else |
---|
| 1269 | { |
---|
| 1270 | hrdIdx = 0; |
---|
| 1271 | } |
---|
| 1272 | |
---|
| 1273 | TComHRD *hrd = vps->getBspHrd(hrdIdx); |
---|
| 1274 | |
---|
| 1275 | if (hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag()) |
---|
| 1276 | { |
---|
| 1277 | len = hrd->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
| 1278 | } |
---|
| 1279 | else |
---|
| 1280 | { |
---|
| 1281 | len = 23 + 1; |
---|
| 1282 | } |
---|
| 1283 | |
---|
| 1284 | if (hrd->getNalHrdParametersPresentFlag()) |
---|
| 1285 | { |
---|
| 1286 | for(UInt i = 0; i < schedCombCnt; i++) |
---|
| 1287 | { |
---|
| 1288 | READ_CODE( len, uiCode, "nal_initial_arrival_delay" ); sei.m_nalInitialArrivalDelay[i] = uiCode; |
---|
| 1289 | } |
---|
| 1290 | } |
---|
| 1291 | else |
---|
| 1292 | { |
---|
| 1293 | for(UInt i = 0; i < schedCombCnt; i++) |
---|
| 1294 | { |
---|
| 1295 | READ_CODE( len, uiCode, "vcl_initial_arrival_delay" ); sei.m_vclInitialArrivalDelay[i] = uiCode; |
---|
| 1296 | } |
---|
| 1297 | } |
---|
| 1298 | } |
---|
| 1299 | |
---|
[846] | 1300 | #if !REMOVE_BSP_HRD_SEI |
---|
[644] | 1301 | Void SEIReader::xParseSEIBspHrd(SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei) |
---|
| 1302 | { |
---|
| 1303 | UInt uiCode; |
---|
| 1304 | READ_UVLC( uiCode, "sei_num_bsp_hrd_parameters_minus1" ); sei.m_seiNumBspHrdParametersMinus1 = uiCode; |
---|
| 1305 | for (UInt i = 0; i <= sei.m_seiNumBspHrdParametersMinus1; i++) |
---|
| 1306 | { |
---|
| 1307 | if (i > 0) |
---|
| 1308 | { |
---|
| 1309 | READ_FLAG( uiCode, "sei_bsp_cprms_present_flag" ); sei.m_seiBspCprmsPresentFlag[i] = uiCode; |
---|
| 1310 | } |
---|
| 1311 | xParseHrdParameters(sei.hrd, i==0 ? 1 : sei.m_seiBspCprmsPresentFlag[i], nestingSei.m_nestingMaxTemporalIdPlus1[0]-1); |
---|
| 1312 | } |
---|
| 1313 | for (UInt h = 0; h <= nestingSei.m_nestingNumOpsMinus1; h++) |
---|
| 1314 | { |
---|
| 1315 | UInt lsIdx = nestingSei.m_nestingOpIdx[h]; |
---|
| 1316 | READ_UVLC( uiCode, "num_sei_bitstream_partitions_minus1[i]"); sei.m_seiNumBitstreamPartitionsMinus1[lsIdx] = uiCode; |
---|
[815] | 1317 | #if HRD_BPB |
---|
| 1318 | Int chkPart=0; |
---|
| 1319 | #endif |
---|
| 1320 | UInt i; |
---|
| 1321 | for(i = 0; i <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; i++) |
---|
[644] | 1322 | { |
---|
[815] | 1323 | #if HRD_BPB |
---|
| 1324 | UInt nl=0; UInt j; |
---|
| 1325 | for(j = 0; j < sei.m_vpsMaxLayers; j++) |
---|
| 1326 | { |
---|
| 1327 | if (sei.m_layerIdIncludedFlag[lsIdx][j]) |
---|
| 1328 | { |
---|
| 1329 | nl++; |
---|
| 1330 | } |
---|
| 1331 | } |
---|
| 1332 | for (j = 0; j < nl; j++) |
---|
| 1333 | { |
---|
| 1334 | #else |
---|
[644] | 1335 | for (UInt j = 0; j < sei.m_vpsMaxLayers; j++) |
---|
| 1336 | { |
---|
| 1337 | if (sei.m_layerIdIncludedFlag[lsIdx][j]) |
---|
| 1338 | { |
---|
[815] | 1339 | #endif |
---|
[644] | 1340 | READ_FLAG( uiCode, "sei_layer_in_bsp_flag[lsIdx][i][j]" ); sei.m_seiLayerInBspFlag[lsIdx][i][j] = uiCode; |
---|
| 1341 | } |
---|
[815] | 1342 | #if !HRD_BPB |
---|
[644] | 1343 | } |
---|
[815] | 1344 | #endif |
---|
| 1345 | #if HRD_BPB |
---|
| 1346 | chkPart+=sei.m_seiLayerInBspFlag[lsIdx][i][j]; |
---|
| 1347 | #endif |
---|
[644] | 1348 | } |
---|
[815] | 1349 | #if HRD_BPB |
---|
| 1350 | assert(chkPart<=1); |
---|
| 1351 | #endif |
---|
| 1352 | #if HRD_BPB |
---|
| 1353 | if(sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]==0) |
---|
| 1354 | { |
---|
| 1355 | Int chkPartition1=0; Int chkPartition2=0; |
---|
| 1356 | for (UInt j = 0; j < sei.m_vpsMaxLayers; j++) |
---|
| 1357 | { |
---|
| 1358 | if( sei.m_layerIdIncludedFlag[lsIdx][j] ) |
---|
| 1359 | { |
---|
| 1360 | chkPartition1+=sei.m_seiLayerInBspFlag[lsIdx][0][j]; |
---|
| 1361 | chkPartition2++; |
---|
| 1362 | } |
---|
| 1363 | } |
---|
| 1364 | assert(chkPartition1!=chkPartition2); |
---|
| 1365 | } |
---|
| 1366 | #endif |
---|
| 1367 | |
---|
[644] | 1368 | READ_UVLC( uiCode, "sei_num_bsp_sched_combinations_minus1[i]"); sei.m_seiNumBspSchedCombinationsMinus1[lsIdx] = uiCode; |
---|
[815] | 1369 | for (i = 0; i <= sei.m_seiNumBspSchedCombinationsMinus1[lsIdx]; i++) |
---|
[644] | 1370 | { |
---|
| 1371 | for (UInt j = 0; j <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; j++) |
---|
| 1372 | { |
---|
| 1373 | READ_UVLC( uiCode, "sei_bsp_comb_hrd_idx[lsIdx][i][j]"); sei.m_seiBspCombHrdIdx[lsIdx][i][j] = uiCode; |
---|
[815] | 1374 | #if HRD_BPB |
---|
| 1375 | assert(uiCode <= sei.m_seiNumBspHrdParametersMinus1); |
---|
| 1376 | #endif |
---|
[644] | 1377 | READ_UVLC( uiCode, "sei_bsp_comb_sched_idx[lsIdx][i][j]"); sei.m_seiBspCombScheddx[lsIdx][i][j] = uiCode; |
---|
[815] | 1378 | #if HRD_BPB |
---|
| 1379 | assert(uiCode <= sei.hrd->getCpbCntMinus1( sps->getMaxTLayers()-1 )); |
---|
| 1380 | #endif |
---|
| 1381 | |
---|
[644] | 1382 | } |
---|
| 1383 | } |
---|
| 1384 | } |
---|
| 1385 | } |
---|
[846] | 1386 | #endif |
---|
[644] | 1387 | |
---|
| 1388 | Void SEIReader::xParseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1) |
---|
| 1389 | { |
---|
| 1390 | UInt uiCode; |
---|
| 1391 | if( commonInfPresentFlag ) |
---|
| 1392 | { |
---|
| 1393 | READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
| 1394 | READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
| 1395 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
| 1396 | { |
---|
| 1397 | READ_FLAG( uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
---|
| 1398 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 1399 | { |
---|
| 1400 | READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
---|
| 1401 | READ_CODE( 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 1402 | READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
---|
| 1403 | READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
---|
| 1404 | } |
---|
| 1405 | READ_CODE( 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
---|
| 1406 | READ_CODE( 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
---|
| 1407 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 1408 | { |
---|
| 1409 | READ_CODE( 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
---|
| 1410 | } |
---|
| 1411 | READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 1412 | READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 1413 | READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
---|
| 1414 | } |
---|
| 1415 | } |
---|
| 1416 | Int i, j, nalOrVcl; |
---|
| 1417 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
| 1418 | { |
---|
| 1419 | READ_FLAG( uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
---|
| 1420 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
| 1421 | { |
---|
| 1422 | READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
---|
| 1423 | } |
---|
| 1424 | else |
---|
| 1425 | { |
---|
| 1426 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
| 1427 | } |
---|
| 1428 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
---|
| 1429 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
---|
| 1430 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
| 1431 | { |
---|
| 1432 | READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
---|
| 1433 | } |
---|
| 1434 | else |
---|
| 1435 | { |
---|
| 1436 | READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
---|
| 1437 | } |
---|
| 1438 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
| 1439 | { |
---|
| 1440 | READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
---|
| 1441 | } |
---|
| 1442 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
| 1443 | { |
---|
| 1444 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
| 1445 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
| 1446 | { |
---|
| 1447 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
| 1448 | { |
---|
| 1449 | READ_UVLC( uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 1450 | READ_UVLC( uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 1451 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 1452 | { |
---|
| 1453 | READ_UVLC( uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 1454 | READ_UVLC( uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 1455 | } |
---|
| 1456 | READ_FLAG( uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
---|
| 1457 | } |
---|
| 1458 | } |
---|
| 1459 | } |
---|
| 1460 | } |
---|
| 1461 | } |
---|
| 1462 | #endif |
---|
| 1463 | |
---|
[815] | 1464 | #if Q0078_ADD_LAYER_SETS |
---|
| 1465 | |
---|
| 1466 | #if LAYERS_NOT_PRESENT_SEI |
---|
| 1467 | Void SEIReader::xParseSEIOutputLayerSetNesting(SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps) |
---|
| 1468 | #else |
---|
| 1469 | Void SEIReader::xParseSEIOutputLayerSetNesting(SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComSPS *sps) |
---|
| 1470 | #endif |
---|
| 1471 | { |
---|
| 1472 | UInt uiCode; |
---|
| 1473 | SEIMessages seis; |
---|
| 1474 | |
---|
| 1475 | READ_FLAG(uiCode, "ols_flag"); sei.m_olsFlag = uiCode; |
---|
| 1476 | READ_UVLC(uiCode, "num_ols_indices_minus1"); sei.m_numOlsIndicesMinus1 = uiCode; |
---|
| 1477 | |
---|
| 1478 | for (Int i = 0; i <= sei.m_numOlsIndicesMinus1; i++) |
---|
| 1479 | { |
---|
| 1480 | READ_UVLC(uiCode, "ols_idx[i]"); sei.m_olsIdx[i] = uiCode; |
---|
| 1481 | } |
---|
| 1482 | |
---|
| 1483 | // byte alignment |
---|
| 1484 | while (m_pcBitstream->getNumBitsRead() % 8 != 0) |
---|
| 1485 | { |
---|
| 1486 | UInt code; |
---|
| 1487 | READ_FLAG(code, "ols_nesting_zero_bit"); |
---|
| 1488 | } |
---|
| 1489 | |
---|
| 1490 | sei.m_callerOwnsSEIs = false; |
---|
| 1491 | |
---|
| 1492 | // read nested SEI messages |
---|
| 1493 | do { |
---|
| 1494 | #if O0164_MULTI_LAYER_HRD |
---|
| 1495 | #if LAYERS_NOT_PRESENT_SEI |
---|
| 1496 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps); |
---|
| 1497 | #else |
---|
| 1498 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps); |
---|
| 1499 | #endif |
---|
| 1500 | #else |
---|
| 1501 | #if LAYERS_NOT_PRESENT_SEI |
---|
| 1502 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps); |
---|
| 1503 | #else |
---|
| 1504 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps); |
---|
| 1505 | #endif |
---|
| 1506 | #endif |
---|
| 1507 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
---|
| 1508 | |
---|
| 1509 | } |
---|
| 1510 | |
---|
| 1511 | Void SEIReader::xParseSEIVPSRewriting(SEIVPSRewriting &sei) |
---|
| 1512 | { |
---|
| 1513 | } |
---|
| 1514 | |
---|
| 1515 | #endif |
---|
| 1516 | |
---|
[595] | 1517 | #endif //SVC_EXTENSION |
---|
| 1518 | |
---|
[313] | 1519 | //! \} |
---|