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