[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 | * |
---|
[1549] | 6 | * Copyright (c) 2010-2016, 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 | #include "TLibCommon/TComBitCounter.h" |
---|
| 35 | #include "TLibCommon/TComBitStream.h" |
---|
| 36 | #include "TLibCommon/SEI.h" |
---|
| 37 | #include "TLibCommon/TComSlice.h" |
---|
[1029] | 38 | #include "TLibCommon/TComPicYuv.h" |
---|
[313] | 39 | #include "SEIwrite.h" |
---|
| 40 | |
---|
| 41 | //! \ingroup TLibEncoder |
---|
| 42 | //! \{ |
---|
| 43 | |
---|
| 44 | #if ENC_DEC_TRACE |
---|
| 45 | Void xTraceSEIHeader() |
---|
| 46 | { |
---|
| 47 | fprintf( g_hTrace, "=========== SEI message ===========\n"); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | Void xTraceSEIMessageType(SEI::PayloadType payloadType) |
---|
| 51 | { |
---|
[1029] | 52 | fprintf( g_hTrace, "=========== %s SEI message ===========\n", SEI::getSEIMessageString(payloadType)); |
---|
[313] | 53 | } |
---|
| 54 | #endif |
---|
| 55 | |
---|
[644] | 56 | #if O0164_MULTI_LAYER_HRD |
---|
[1235] | 57 | Void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting* nestingSeiPtr, const SEIBspNesting* bspNestingSeiPtr) |
---|
[894] | 58 | #else |
---|
[1235] | 59 | Void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, const TComSPS *sps) |
---|
[644] | 60 | #endif |
---|
[313] | 61 | { |
---|
[1185] | 62 | #if SVC_EXTENSION |
---|
[894] | 63 | SEIScalableNesting nestingSei; |
---|
| 64 | SEIBspNesting bspNestingSei; |
---|
| 65 | if( nestingSeiPtr ) |
---|
| 66 | { |
---|
| 67 | nestingSei = *nestingSeiPtr; |
---|
| 68 | } |
---|
| 69 | if( bspNestingSeiPtr ) |
---|
| 70 | { |
---|
| 71 | bspNestingSei = *bspNestingSeiPtr; |
---|
| 72 | } |
---|
| 73 | #endif |
---|
[313] | 74 | switch (sei.payloadType()) |
---|
| 75 | { |
---|
| 76 | case SEI::USER_DATA_UNREGISTERED: |
---|
| 77 | xWriteSEIuserDataUnregistered(*static_cast<const SEIuserDataUnregistered*>(&sei)); |
---|
| 78 | break; |
---|
| 79 | case SEI::ACTIVE_PARAMETER_SETS: |
---|
[1029] | 80 | xWriteSEIActiveParameterSets(*static_cast<const SEIActiveParameterSets*>(& sei)); |
---|
[313] | 81 | break; |
---|
[1185] | 82 | #if SVC_EXTENSION |
---|
[894] | 83 | case SEI::DECODING_UNIT_INFO: |
---|
| 84 | xWriteSEIDecodingUnitInfo(*static_cast<const SEIDecodingUnitInfo*>(& sei), sps, nestingSeiPtr, bspNestingSeiPtr, vps); |
---|
| 85 | break; |
---|
[313] | 86 | case SEI::BUFFERING_PERIOD: |
---|
[894] | 87 | xWriteSEIBufferingPeriod(*static_cast<const SEIBufferingPeriod*>(&sei), sps, nestingSeiPtr, bspNestingSeiPtr, vps); |
---|
| 88 | break; |
---|
| 89 | case SEI::PICTURE_TIMING: |
---|
| 90 | xWriteSEIPictureTiming(*static_cast<const SEIPictureTiming*>(&sei), sps, nestingSeiPtr, bspNestingSeiPtr, vps); |
---|
| 91 | break; |
---|
| 92 | #else |
---|
| 93 | case SEI::DECODING_UNIT_INFO: |
---|
| 94 | xWriteSEIDecodingUnitInfo(*static_cast<const SEIDecodingUnitInfo*>(& sei), sps); |
---|
| 95 | break; |
---|
[1319] | 96 | #endif |
---|
| 97 | case SEI::DECODED_PICTURE_HASH: |
---|
| 98 | xWriteSEIDecodedPictureHash(*static_cast<const SEIDecodedPictureHash*>(&sei)); |
---|
| 99 | break; |
---|
| 100 | #if !SVC_EXTENSION |
---|
[894] | 101 | case SEI::BUFFERING_PERIOD: |
---|
[313] | 102 | xWriteSEIBufferingPeriod(*static_cast<const SEIBufferingPeriod*>(&sei), sps); |
---|
| 103 | break; |
---|
| 104 | case SEI::PICTURE_TIMING: |
---|
| 105 | xWriteSEIPictureTiming(*static_cast<const SEIPictureTiming*>(&sei), sps); |
---|
| 106 | break; |
---|
[894] | 107 | #endif |
---|
[313] | 108 | case SEI::RECOVERY_POINT: |
---|
| 109 | xWriteSEIRecoveryPoint(*static_cast<const SEIRecoveryPoint*>(&sei)); |
---|
| 110 | break; |
---|
| 111 | case SEI::FRAME_PACKING: |
---|
| 112 | xWriteSEIFramePacking(*static_cast<const SEIFramePacking*>(&sei)); |
---|
| 113 | break; |
---|
[1029] | 114 | case SEI::SEGM_RECT_FRAME_PACKING: |
---|
| 115 | xWriteSEISegmentedRectFramePacking(*static_cast<const SEISegmentedRectFramePacking*>(&sei)); |
---|
| 116 | break; |
---|
[313] | 117 | case SEI::DISPLAY_ORIENTATION: |
---|
| 118 | xWriteSEIDisplayOrientation(*static_cast<const SEIDisplayOrientation*>(&sei)); |
---|
| 119 | break; |
---|
| 120 | case SEI::TEMPORAL_LEVEL0_INDEX: |
---|
| 121 | xWriteSEITemporalLevel0Index(*static_cast<const SEITemporalLevel0Index*>(&sei)); |
---|
| 122 | break; |
---|
| 123 | case SEI::REGION_REFRESH_INFO: |
---|
| 124 | xWriteSEIGradualDecodingRefreshInfo(*static_cast<const SEIGradualDecodingRefreshInfo*>(&sei)); |
---|
| 125 | break; |
---|
[1029] | 126 | case SEI::NO_DISPLAY: |
---|
| 127 | xWriteSEINoDisplay(*static_cast<const SEINoDisplay*>(&sei)); |
---|
| 128 | break; |
---|
[313] | 129 | case SEI::TONE_MAPPING_INFO: |
---|
| 130 | xWriteSEIToneMappingInfo(*static_cast<const SEIToneMappingInfo*>(&sei)); |
---|
| 131 | break; |
---|
[595] | 132 | case SEI::SOP_DESCRIPTION: |
---|
| 133 | xWriteSEISOPDescription(*static_cast<const SEISOPDescription*>(&sei)); |
---|
| 134 | break; |
---|
| 135 | case SEI::SCALABLE_NESTING: |
---|
[644] | 136 | #if O0164_MULTI_LAYER_HRD |
---|
| 137 | xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), vps, sps); |
---|
| 138 | #else |
---|
[595] | 139 | xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), sps); |
---|
[644] | 140 | #endif |
---|
[595] | 141 | break; |
---|
[1434] | 142 | case SEI::CHROMA_RESAMPLING_FILTER_HINT: |
---|
| 143 | xWriteSEIChromaResamplingFilterHint(*static_cast<const SEIChromaResamplingFilterHint*>(&sei)); |
---|
[1029] | 144 | break; |
---|
| 145 | case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS: |
---|
[1307] | 146 | xWriteSEITempMotionConstrainedTileSets(*static_cast<const SEITempMotionConstrainedTileSets*>(&sei)); |
---|
[1029] | 147 | break; |
---|
| 148 | case SEI::TIME_CODE: |
---|
| 149 | xWriteSEITimeCode(*static_cast<const SEITimeCode*>(&sei)); |
---|
| 150 | break; |
---|
| 151 | case SEI::KNEE_FUNCTION_INFO: |
---|
| 152 | xWriteSEIKneeFunctionInfo(*static_cast<const SEIKneeFunctionInfo*>(&sei)); |
---|
| 153 | break; |
---|
| 154 | case SEI::COLOUR_REMAPPING_INFO: |
---|
| 155 | xWriteSEIColourRemappingInfo(*static_cast<const SEIColourRemappingInfo*>(&sei)); |
---|
| 156 | break; |
---|
[1460] | 157 | case SEI::MASTERING_DISPLAY_COLOUR_VOLUME: |
---|
| 158 | xWriteSEIMasteringDisplayColourVolume(*static_cast<const SEIMasteringDisplayColourVolume*>(&sei)); |
---|
| 159 | break; |
---|
[1538] | 160 | #if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI |
---|
| 161 | case SEI::ALTERNATIVE_TRANSFER_CHARACTERISTICS: |
---|
| 162 | xWriteSEIAlternativeTransferCharacteristics(*static_cast<const SEIAlternativeTransferCharacteristics*>(&sei)); |
---|
| 163 | break; |
---|
| 164 | #endif |
---|
[1572] | 165 | case SEI::GREEN_METADATA: |
---|
| 166 | xWriteSEIGreenMetadataInfo(*static_cast<const SEIGreenMetadataInfo*>(&sei)); |
---|
| 167 | break; |
---|
[1538] | 168 | |
---|
[595] | 169 | #if SVC_EXTENSION |
---|
[588] | 170 | #if LAYERS_NOT_PRESENT_SEI |
---|
| 171 | case SEI::LAYERS_NOT_PRESENT: |
---|
| 172 | xWriteSEILayersNotPresent(*static_cast<const SEILayersNotPresent*>(&sei)); |
---|
[313] | 173 | break; |
---|
| 174 | #endif |
---|
[442] | 175 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
| 176 | case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: |
---|
| 177 | xWriteSEIInterLayerConstrainedTileSets(*static_cast<const SEIInterLayerConstrainedTileSets*>(&sei)); |
---|
| 178 | break; |
---|
| 179 | #endif |
---|
[588] | 180 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
| 181 | case SEI::SUB_BITSTREAM_PROPERTY: |
---|
| 182 | xWriteSEISubBitstreamProperty(*static_cast<const SEISubBitstreamProperty*>(&sei)); |
---|
| 183 | break; |
---|
| 184 | #endif |
---|
[644] | 185 | #if O0164_MULTI_LAYER_HRD |
---|
| 186 | case SEI::BSP_NESTING: |
---|
| 187 | xWriteSEIBspNesting(bs, *static_cast<const SEIBspNesting*>(&sei), vps, sps, nestingSei); |
---|
| 188 | break; |
---|
| 189 | case SEI::BSP_INITIAL_ARRIVAL_TIME: |
---|
| 190 | xWriteSEIBspInitialArrivalTime(*static_cast<const SEIBspInitialArrivalTime*>(&sei), vps, sps, nestingSei, bspNestingSei); |
---|
| 191 | break; |
---|
| 192 | #endif |
---|
[815] | 193 | #if Q0189_TMVP_CONSTRAINTS |
---|
| 194 | case SEI::TMVP_CONSTRAINTS: |
---|
| 195 | xWriteSEITMVPConstraints(*static_cast<const SEITMVPConstrains*>(&sei)); |
---|
| 196 | break; |
---|
| 197 | #endif |
---|
| 198 | #if Q0247_FRAME_FIELD_INFO |
---|
| 199 | case SEI::FRAME_FIELD_INFO: |
---|
| 200 | xWriteSEIFrameFieldInfo(*static_cast<const SEIFrameFieldInfo*>(&sei)); |
---|
| 201 | break; |
---|
| 202 | #endif |
---|
[1037] | 203 | #if P0123_ALPHA_CHANNEL_SEI |
---|
| 204 | case SEI::ALPHA_CHANNEL_INFO: |
---|
| 205 | xWriteSEIAlphaChannelInfo(*static_cast<const SEIAlphaChannelInfo*>(&sei)); |
---|
| 206 | break; |
---|
| 207 | #endif |
---|
[912] | 208 | #if Q0096_OVERLAY_SEI |
---|
| 209 | case SEI::OVERLAY_INFO: |
---|
| 210 | xWriteSEIOverlayInfo(*static_cast<const SEIOverlayInfo*>(&sei)); |
---|
| 211 | break; |
---|
| 212 | #endif |
---|
[595] | 213 | #endif //SVC_EXTENSION |
---|
[313] | 214 | default: |
---|
[1434] | 215 | assert(!"Trying to write unhandled SEI message"); |
---|
[1029] | 216 | break; |
---|
[313] | 217 | } |
---|
[1029] | 218 | xWriteByteAlign(); |
---|
[313] | 219 | } |
---|
| 220 | |
---|
| 221 | /** |
---|
[1273] | 222 | * marshal all SEI messages in provided list into one bitstream bs |
---|
[313] | 223 | */ |
---|
[644] | 224 | #if O0164_MULTI_LAYER_HRD |
---|
[1352] | 225 | Void SEIWriter::writeSEImessages(TComBitIf& bs, const SEIMessages &seiList, const TComVPS *vps, const TComSPS *sps, Bool isNested, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei) |
---|
[644] | 226 | #else |
---|
[1352] | 227 | Void SEIWriter::writeSEImessages(TComBitIf& bs, const SEIMessages &seiList, const TComSPS *sps, Bool isNested) |
---|
[644] | 228 | #endif |
---|
[313] | 229 | { |
---|
[1273] | 230 | #if ENC_DEC_TRACE |
---|
| 231 | if (g_HLSTraceEnable) |
---|
| 232 | xTraceSEIHeader(); |
---|
| 233 | #endif |
---|
| 234 | |
---|
[313] | 235 | TComBitCounter bs_count; |
---|
| 236 | |
---|
[1273] | 237 | for (SEIMessages::const_iterator sei=seiList.begin(); sei!=seiList.end(); sei++) |
---|
| 238 | { |
---|
| 239 | // calculate how large the payload data is |
---|
| 240 | // TODO: this would be far nicer if it used vectored buffers |
---|
| 241 | bs_count.resetBits(); |
---|
| 242 | setBitstream(&bs_count); |
---|
[313] | 243 | |
---|
| 244 | #if ENC_DEC_TRACE |
---|
[1273] | 245 | Bool traceEnable = g_HLSTraceEnable; |
---|
| 246 | g_HLSTraceEnable = false; |
---|
[313] | 247 | #endif |
---|
[644] | 248 | #if O0164_MULTI_LAYER_HRD |
---|
[1273] | 249 | xWriteSEIpayloadData(bs_count, **sei, vps, sps, nestingSei, bspNestingSei); |
---|
[894] | 250 | #else |
---|
[1273] | 251 | xWriteSEIpayloadData(bs_count, **sei, sps); |
---|
[644] | 252 | #endif |
---|
[313] | 253 | #if ENC_DEC_TRACE |
---|
[1273] | 254 | g_HLSTraceEnable = traceEnable; |
---|
[313] | 255 | #endif |
---|
[1273] | 256 | UInt payload_data_num_bits = bs_count.getNumberOfWrittenBits(); |
---|
| 257 | assert(0 == payload_data_num_bits % 8); |
---|
[313] | 258 | |
---|
[1273] | 259 | setBitstream(&bs); |
---|
| 260 | UInt payloadType = (*sei)->payloadType(); |
---|
| 261 | for (; payloadType >= 0xff; payloadType -= 0xff) |
---|
| 262 | { |
---|
| 263 | WRITE_CODE(0xff, 8, "payload_type"); |
---|
| 264 | } |
---|
| 265 | WRITE_CODE(payloadType, 8, "payload_type"); |
---|
[313] | 266 | |
---|
[1273] | 267 | UInt payloadSize = payload_data_num_bits/8; |
---|
| 268 | for (; payloadSize >= 0xff; payloadSize -= 0xff) |
---|
| 269 | { |
---|
| 270 | WRITE_CODE(0xff, 8, "payload_size"); |
---|
| 271 | } |
---|
| 272 | WRITE_CODE(payloadSize, 8, "payload_size"); |
---|
[313] | 273 | |
---|
[1273] | 274 | /* payloadData */ |
---|
[313] | 275 | #if ENC_DEC_TRACE |
---|
[1273] | 276 | if (g_HLSTraceEnable) |
---|
| 277 | xTraceSEIMessageType((*sei)->payloadType()); |
---|
[313] | 278 | #endif |
---|
| 279 | |
---|
[644] | 280 | #if O0164_MULTI_LAYER_HRD |
---|
[1273] | 281 | xWriteSEIpayloadData(bs, **sei, vps, sps, nestingSei, bspNestingSei); |
---|
[894] | 282 | #else |
---|
[1273] | 283 | xWriteSEIpayloadData(bs, **sei, sps); |
---|
[644] | 284 | #endif |
---|
[1273] | 285 | } |
---|
[1352] | 286 | if (!isNested) |
---|
| 287 | { |
---|
| 288 | xWriteRbspTrailingBits(); |
---|
| 289 | } |
---|
[313] | 290 | } |
---|
| 291 | |
---|
| 292 | /** |
---|
| 293 | * marshal a user_data_unregistered SEI message sei, storing the marshalled |
---|
| 294 | * representation in bitstream bs. |
---|
| 295 | */ |
---|
| 296 | Void SEIWriter::xWriteSEIuserDataUnregistered(const SEIuserDataUnregistered &sei) |
---|
| 297 | { |
---|
[1029] | 298 | for (UInt i = 0; i < ISO_IEC_11578_LEN; i++) |
---|
[313] | 299 | { |
---|
| 300 | WRITE_CODE(sei.uuid_iso_iec_11578[i], 8 , "sei.uuid_iso_iec_11578[i]"); |
---|
| 301 | } |
---|
| 302 | |
---|
| 303 | for (UInt i = 0; i < sei.userDataLength; i++) |
---|
| 304 | { |
---|
| 305 | WRITE_CODE(sei.userData[i], 8 , "user_data"); |
---|
| 306 | } |
---|
| 307 | } |
---|
| 308 | |
---|
| 309 | /** |
---|
| 310 | * marshal a decoded picture hash SEI message, storing the marshalled |
---|
| 311 | * representation in bitstream bs. |
---|
| 312 | */ |
---|
| 313 | Void SEIWriter::xWriteSEIDecodedPictureHash(const SEIDecodedPictureHash& sei) |
---|
| 314 | { |
---|
[1442] | 315 | const TChar *traceString="\0"; |
---|
[1029] | 316 | switch (sei.method) |
---|
| 317 | { |
---|
[1459] | 318 | case HASHTYPE_MD5: traceString="picture_md5"; break; |
---|
| 319 | case HASHTYPE_CRC: traceString="picture_crc"; break; |
---|
| 320 | case HASHTYPE_CHECKSUM: traceString="picture_checksum"; break; |
---|
[1029] | 321 | default: assert(false); break; |
---|
| 322 | } |
---|
[313] | 323 | |
---|
[1029] | 324 | if (traceString != 0) //use of this variable is needed to avoid a compiler error with G++ 4.6.1 |
---|
[313] | 325 | { |
---|
[1029] | 326 | WRITE_CODE(sei.method, 8, "hash_type"); |
---|
[1273] | 327 | for(UInt i=0; i<UInt(sei.m_pictureHash.hash.size()); i++) |
---|
[313] | 328 | { |
---|
[1273] | 329 | WRITE_CODE(sei.m_pictureHash.hash[i], 8, traceString); |
---|
[313] | 330 | } |
---|
| 331 | } |
---|
| 332 | } |
---|
| 333 | |
---|
| 334 | Void SEIWriter::xWriteSEIActiveParameterSets(const SEIActiveParameterSets& sei) |
---|
| 335 | { |
---|
[713] | 336 | WRITE_CODE(sei.activeVPSId, 4, "active_video_parameter_set_id"); |
---|
| 337 | WRITE_FLAG(sei.m_selfContainedCvsFlag, "self_contained_cvs_flag"); |
---|
| 338 | WRITE_FLAG(sei.m_noParameterSetUpdateFlag, "no_parameter_set_update_flag"); |
---|
[1029] | 339 | WRITE_UVLC(sei.numSpsIdsMinus1, "num_sps_ids_minus1"); |
---|
[313] | 340 | |
---|
[713] | 341 | assert (sei.activeSeqParameterSetId.size() == (sei.numSpsIdsMinus1 + 1)); |
---|
[313] | 342 | |
---|
[713] | 343 | for (Int i = 0; i < sei.activeSeqParameterSetId.size(); i++) |
---|
[313] | 344 | { |
---|
[713] | 345 | WRITE_UVLC(sei.activeSeqParameterSetId[i], "active_seq_parameter_set_id"); |
---|
[313] | 346 | } |
---|
[884] | 347 | #if R0247_SEI_ACTIVE |
---|
| 348 | for (Int i = 1; i < sei.activeSeqParameterSetId.size(); i++) |
---|
| 349 | { |
---|
| 350 | WRITE_UVLC(sei.layerSpsIdx[i], "layer_sps_idx"); |
---|
| 351 | } |
---|
| 352 | #endif |
---|
[313] | 353 | } |
---|
| 354 | |
---|
[1185] | 355 | #if SVC_EXTENSION |
---|
[1235] | 356 | Void SEIWriter::xWriteSEIDecodingUnitInfo(const SEIDecodingUnitInfo& sei, const TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, const TComVPS *vps) |
---|
[313] | 357 | { |
---|
[1235] | 358 | const TComHRD *hrd; |
---|
[894] | 359 | if( bspNestingSei ) // If DU info SEI contained inside a BSP nesting SEI message |
---|
| 360 | { |
---|
| 361 | assert( nestingSei ); |
---|
| 362 | Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx; |
---|
| 363 | Int seiOlsIdx = bspNestingSei->m_seiOlsIdx; |
---|
| 364 | Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1; |
---|
| 365 | Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; |
---|
| 366 | std::vector<Int> hrdIdx(maxValues, 0); |
---|
[1235] | 367 | std::vector<const TComHRD*> hrdVec; |
---|
[894] | 368 | std::vector<Int> syntaxElemLen(maxValues, 0); |
---|
| 369 | for(Int i = 0; i < maxValues; i++) |
---|
| 370 | { |
---|
| 371 | hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); |
---|
| 372 | hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); |
---|
| 373 | |
---|
| 374 | syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
| 375 | if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) |
---|
| 376 | { |
---|
| 377 | assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 |
---|
| 378 | } |
---|
| 379 | if( i > 0 ) |
---|
| 380 | { |
---|
| 381 | assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); |
---|
| 382 | assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag() == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() ); |
---|
| 383 | assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); |
---|
| 384 | // To be done: Check CpbDpbDelaysPresentFlag |
---|
| 385 | } |
---|
| 386 | } |
---|
| 387 | hrd = hrdVec[0]; |
---|
| 388 | } |
---|
| 389 | else |
---|
| 390 | { |
---|
[1235] | 391 | const TComVUI *vui = sps->getVuiParameters(); |
---|
[894] | 392 | hrd = vui->getHrdParameters(); |
---|
| 393 | } |
---|
[1029] | 394 | |
---|
[313] | 395 | WRITE_UVLC(sei.m_decodingUnitIdx, "decoding_unit_idx"); |
---|
[894] | 396 | if(hrd->getSubPicCpbParamsInPicTimingSEIFlag()) |
---|
[313] | 397 | { |
---|
[894] | 398 | WRITE_CODE( sei.m_duSptCpbRemovalDelay, (hrd->getDuCpbRemovalDelayLengthMinus1() + 1), "du_spt_cpb_removal_delay"); |
---|
[313] | 399 | } |
---|
| 400 | WRITE_FLAG( sei.m_dpbOutputDuDelayPresentFlag, "dpb_output_du_delay_present_flag"); |
---|
| 401 | if(sei.m_dpbOutputDuDelayPresentFlag) |
---|
| 402 | { |
---|
[1029] | 403 | WRITE_CODE(sei.m_picSptDpbOutputDuDelay, hrd->getDpbOutputDelayDuLengthMinus1() + 1, "pic_spt_dpb_output_du_delay"); |
---|
[313] | 404 | } |
---|
[1185] | 405 | } |
---|
[1029] | 406 | #else |
---|
[1235] | 407 | Void SEIWriter::xWriteSEIDecodingUnitInfo(const SEIDecodingUnitInfo& sei, const TComSPS *sps) |
---|
[1185] | 408 | { |
---|
[1235] | 409 | const TComVUI *vui = sps->getVuiParameters(); |
---|
[1029] | 410 | WRITE_UVLC(sei.m_decodingUnitIdx, "decoding_unit_idx"); |
---|
| 411 | if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag()) |
---|
| 412 | { |
---|
[1319] | 413 | WRITE_CODE( sei.m_duSptCpbRemovalDelay, (vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1), "du_spt_cpb_removal_delay_increment"); |
---|
[1029] | 414 | } |
---|
| 415 | WRITE_FLAG( sei.m_dpbOutputDuDelayPresentFlag, "dpb_output_du_delay_present_flag"); |
---|
| 416 | if(sei.m_dpbOutputDuDelayPresentFlag) |
---|
| 417 | { |
---|
| 418 | WRITE_CODE(sei.m_picSptDpbOutputDuDelay, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, "pic_spt_dpb_output_du_delay"); |
---|
| 419 | } |
---|
[1185] | 420 | } |
---|
[1029] | 421 | #endif |
---|
[313] | 422 | |
---|
[1185] | 423 | #if SVC_EXTENSION |
---|
[1235] | 424 | Void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei, const TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, const TComVPS *vps) |
---|
[894] | 425 | #else |
---|
[1235] | 426 | Void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei, const TComSPS *sps) |
---|
[894] | 427 | #endif |
---|
[313] | 428 | { |
---|
| 429 | Int i, nalOrVcl; |
---|
[1185] | 430 | #if SVC_EXTENSION |
---|
[1235] | 431 | const TComHRD *hrd; |
---|
[894] | 432 | if( bspNestingSei ) // If BP SEI contained inside a BSP nesting SEI message |
---|
| 433 | { |
---|
| 434 | assert( nestingSei ); |
---|
| 435 | Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx; |
---|
| 436 | Int seiOlsIdx = bspNestingSei->m_seiOlsIdx; |
---|
| 437 | Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1; |
---|
| 438 | Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; |
---|
| 439 | std::vector<Int> hrdIdx(maxValues, 0); |
---|
[1235] | 440 | std::vector<const TComHRD*> hrdVec; |
---|
[894] | 441 | std::vector<Int> syntaxElemLen(maxValues, 0); |
---|
[1379] | 442 | |
---|
| 443 | Int schedSelIdx = 0; |
---|
| 444 | |
---|
[894] | 445 | for(i = 0; i < maxValues; i++) |
---|
| 446 | { |
---|
| 447 | hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); |
---|
| 448 | hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); |
---|
| 449 | |
---|
| 450 | syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
| 451 | if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) |
---|
| 452 | { |
---|
| 453 | assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 |
---|
| 454 | } |
---|
| 455 | if( i > 0 ) |
---|
| 456 | { |
---|
| 457 | assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() ); |
---|
| 458 | assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); |
---|
| 459 | assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); |
---|
| 460 | } |
---|
| 461 | } |
---|
[1379] | 462 | hrd = hrdVec[schedSelIdx]; |
---|
[894] | 463 | } |
---|
| 464 | else |
---|
| 465 | { |
---|
[1235] | 466 | const TComVUI *vui = sps->getVuiParameters(); |
---|
[894] | 467 | hrd = vui->getHrdParameters(); |
---|
| 468 | } |
---|
| 469 | // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently. |
---|
| 470 | #else |
---|
[1235] | 471 | const TComVUI *vui = sps->getVuiParameters(); |
---|
| 472 | const TComHRD *hrd = vui->getHrdParameters(); |
---|
[894] | 473 | #endif |
---|
[313] | 474 | |
---|
| 475 | WRITE_UVLC( sei.m_bpSeqParameterSetId, "bp_seq_parameter_set_id" ); |
---|
| 476 | if( !hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 477 | { |
---|
[595] | 478 | WRITE_FLAG( sei.m_rapCpbParamsPresentFlag, "irap_cpb_params_present_flag" ); |
---|
[313] | 479 | } |
---|
| 480 | if( sei.m_rapCpbParamsPresentFlag ) |
---|
| 481 | { |
---|
| 482 | WRITE_CODE( sei.m_cpbDelayOffset, hrd->getCpbRemovalDelayLengthMinus1() + 1, "cpb_delay_offset" ); |
---|
| 483 | WRITE_CODE( sei.m_dpbDelayOffset, hrd->getDpbOutputDelayLengthMinus1() + 1, "dpb_delay_offset" ); |
---|
| 484 | } |
---|
[595] | 485 | WRITE_FLAG( sei.m_concatenationFlag, "concatenation_flag"); |
---|
| 486 | WRITE_CODE( sei.m_auCpbRemovalDelayDelta - 1, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), "au_cpb_removal_delay_delta_minus1" ); |
---|
[313] | 487 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
| 488 | { |
---|
| 489 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
| 490 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
| 491 | { |
---|
| 492 | for( i = 0; i < ( hrd->getCpbCntMinus1( 0 ) + 1 ); i ++ ) |
---|
| 493 | { |
---|
| 494 | WRITE_CODE( sei.m_initialCpbRemovalDelay[i][nalOrVcl],( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , "initial_cpb_removal_delay" ); |
---|
| 495 | WRITE_CODE( sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl],( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ), "initial_cpb_removal_delay_offset" ); |
---|
| 496 | if( hrd->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag ) |
---|
| 497 | { |
---|
| 498 | WRITE_CODE( sei.m_initialAltCpbRemovalDelay[i][nalOrVcl], ( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , "initial_alt_cpb_removal_delay" ); |
---|
| 499 | WRITE_CODE( sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl], ( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ),"initial_alt_cpb_removal_delay_offset" ); |
---|
| 500 | } |
---|
| 501 | } |
---|
| 502 | } |
---|
| 503 | } |
---|
[644] | 504 | #if P0138_USE_ALT_CPB_PARAMS_FLAG |
---|
| 505 | if (sei.m_useAltCpbParamsFlagPresent) |
---|
| 506 | { |
---|
| 507 | WRITE_FLAG( sei.m_useAltCpbParamsFlag, "use_alt_cpb_params_flag"); |
---|
| 508 | } |
---|
| 509 | #endif |
---|
[313] | 510 | } |
---|
[1185] | 511 | |
---|
| 512 | #if SVC_EXTENSION |
---|
[1235] | 513 | Void SEIWriter::xWriteSEIPictureTiming(const SEIPictureTiming& sei, const TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, const TComVPS *vps) |
---|
[894] | 514 | #else |
---|
[1235] | 515 | Void SEIWriter::xWriteSEIPictureTiming(const SEIPictureTiming& sei, const TComSPS *sps) |
---|
[894] | 516 | #endif |
---|
[313] | 517 | { |
---|
| 518 | Int i; |
---|
[1185] | 519 | #if SVC_EXTENSION |
---|
[1235] | 520 | const TComHRD *hrd; |
---|
| 521 | const TComVUI *vui = sps->getVuiParameters(); |
---|
[894] | 522 | if( bspNestingSei ) // If BP SEI contained inside a BSP nesting SEI message |
---|
| 523 | { |
---|
| 524 | assert( nestingSei ); |
---|
| 525 | Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx; |
---|
| 526 | Int seiOlsIdx = bspNestingSei->m_seiOlsIdx; |
---|
| 527 | Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1; |
---|
| 528 | Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; |
---|
| 529 | std::vector<Int> hrdIdx(maxValues, 0); |
---|
[1235] | 530 | std::vector<const TComHRD*> hrdVec; |
---|
[894] | 531 | std::vector<Int> syntaxElemLen(maxValues, 0); |
---|
| 532 | for(i = 0; i < maxValues; i++) |
---|
| 533 | { |
---|
| 534 | hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); |
---|
| 535 | hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); |
---|
| 536 | |
---|
| 537 | syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
| 538 | if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) |
---|
| 539 | { |
---|
| 540 | assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 |
---|
| 541 | } |
---|
| 542 | if( i > 0 ) |
---|
| 543 | { |
---|
| 544 | assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); |
---|
| 545 | assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag() == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() ); |
---|
| 546 | assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() ); |
---|
| 547 | assert( hrdVec[i]->getDpbOutputDelayLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayLengthMinus1() ); |
---|
| 548 | assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); |
---|
| 549 | assert( hrdVec[i]->getDuCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getDuCpbRemovalDelayLengthMinus1() ); |
---|
| 550 | // To be done: Check CpbDpbDelaysPresentFlag |
---|
| 551 | } |
---|
| 552 | } |
---|
| 553 | hrd = hrdVec[0]; |
---|
| 554 | } |
---|
| 555 | else |
---|
| 556 | { |
---|
| 557 | hrd = vui->getHrdParameters(); |
---|
| 558 | } |
---|
| 559 | // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently. |
---|
| 560 | #else |
---|
[1235] | 561 | const TComVUI *vui = sps->getVuiParameters(); |
---|
| 562 | const TComHRD *hrd = vui->getHrdParameters(); |
---|
[894] | 563 | #endif |
---|
[313] | 564 | |
---|
[1029] | 565 | if( vui->getFrameFieldInfoPresentFlag() ) |
---|
[313] | 566 | { |
---|
| 567 | WRITE_CODE( sei.m_picStruct, 4, "pic_struct" ); |
---|
| 568 | WRITE_CODE( sei.m_sourceScanType, 2, "source_scan_type" ); |
---|
| 569 | WRITE_FLAG( sei.m_duplicateFlag ? 1 : 0, "duplicate_flag" ); |
---|
| 570 | } |
---|
| 571 | |
---|
| 572 | if( hrd->getCpbDpbDelaysPresentFlag() ) |
---|
| 573 | { |
---|
| 574 | WRITE_CODE( sei.m_auCpbRemovalDelay - 1, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), "au_cpb_removal_delay_minus1" ); |
---|
| 575 | WRITE_CODE( sei.m_picDpbOutputDelay, ( hrd->getDpbOutputDelayLengthMinus1() + 1 ), "pic_dpb_output_delay" ); |
---|
| 576 | if(hrd->getSubPicCpbParamsPresentFlag()) |
---|
| 577 | { |
---|
| 578 | WRITE_CODE(sei.m_picDpbOutputDuDelay, hrd->getDpbOutputDelayDuLengthMinus1()+1, "pic_dpb_output_du_delay" ); |
---|
| 579 | } |
---|
| 580 | if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() ) |
---|
| 581 | { |
---|
| 582 | WRITE_UVLC( sei.m_numDecodingUnitsMinus1, "num_decoding_units_minus1" ); |
---|
| 583 | WRITE_FLAG( sei.m_duCommonCpbRemovalDelayFlag, "du_common_cpb_removal_delay_flag" ); |
---|
| 584 | if( sei.m_duCommonCpbRemovalDelayFlag ) |
---|
| 585 | { |
---|
| 586 | WRITE_CODE( sei.m_duCommonCpbRemovalDelayMinus1, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), "du_common_cpb_removal_delay_minus1" ); |
---|
| 587 | } |
---|
| 588 | for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ ) |
---|
| 589 | { |
---|
| 590 | WRITE_UVLC( sei.m_numNalusInDuMinus1[ i ], "num_nalus_in_du_minus1"); |
---|
| 591 | if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) ) |
---|
| 592 | { |
---|
| 593 | WRITE_CODE( sei.m_duCpbRemovalDelayMinus1[ i ], ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), "du_cpb_removal_delay_minus1" ); |
---|
| 594 | } |
---|
| 595 | } |
---|
| 596 | } |
---|
| 597 | } |
---|
| 598 | } |
---|
| 599 | Void SEIWriter::xWriteSEIRecoveryPoint(const SEIRecoveryPoint& sei) |
---|
| 600 | { |
---|
| 601 | WRITE_SVLC( sei.m_recoveryPocCnt, "recovery_poc_cnt" ); |
---|
| 602 | WRITE_FLAG( sei.m_exactMatchingFlag, "exact_matching_flag" ); |
---|
| 603 | WRITE_FLAG( sei.m_brokenLinkFlag, "broken_link_flag" ); |
---|
| 604 | } |
---|
| 605 | Void SEIWriter::xWriteSEIFramePacking(const SEIFramePacking& sei) |
---|
| 606 | { |
---|
| 607 | WRITE_UVLC( sei.m_arrangementId, "frame_packing_arrangement_id" ); |
---|
| 608 | WRITE_FLAG( sei.m_arrangementCancelFlag, "frame_packing_arrangement_cancel_flag" ); |
---|
| 609 | |
---|
[1246] | 610 | if( sei.m_arrangementCancelFlag == 0 ) |
---|
| 611 | { |
---|
[313] | 612 | WRITE_CODE( sei.m_arrangementType, 7, "frame_packing_arrangement_type" ); |
---|
| 613 | |
---|
| 614 | WRITE_FLAG( sei.m_quincunxSamplingFlag, "quincunx_sampling_flag" ); |
---|
| 615 | WRITE_CODE( sei.m_contentInterpretationType, 6, "content_interpretation_type" ); |
---|
| 616 | WRITE_FLAG( sei.m_spatialFlippingFlag, "spatial_flipping_flag" ); |
---|
| 617 | WRITE_FLAG( sei.m_frame0FlippedFlag, "frame0_flipped_flag" ); |
---|
| 618 | WRITE_FLAG( sei.m_fieldViewsFlag, "field_views_flag" ); |
---|
| 619 | WRITE_FLAG( sei.m_currentFrameIsFrame0Flag, "current_frame_is_frame0_flag" ); |
---|
| 620 | |
---|
| 621 | WRITE_FLAG( sei.m_frame0SelfContainedFlag, "frame0_self_contained_flag" ); |
---|
| 622 | WRITE_FLAG( sei.m_frame1SelfContainedFlag, "frame1_self_contained_flag" ); |
---|
| 623 | |
---|
| 624 | if(sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5) |
---|
| 625 | { |
---|
| 626 | WRITE_CODE( sei.m_frame0GridPositionX, 4, "frame0_grid_position_x" ); |
---|
| 627 | WRITE_CODE( sei.m_frame0GridPositionY, 4, "frame0_grid_position_y" ); |
---|
| 628 | WRITE_CODE( sei.m_frame1GridPositionX, 4, "frame1_grid_position_x" ); |
---|
| 629 | WRITE_CODE( sei.m_frame1GridPositionY, 4, "frame1_grid_position_y" ); |
---|
| 630 | } |
---|
| 631 | |
---|
| 632 | WRITE_CODE( sei.m_arrangementReservedByte, 8, "frame_packing_arrangement_reserved_byte" ); |
---|
| 633 | WRITE_FLAG( sei.m_arrangementPersistenceFlag, "frame_packing_arrangement_persistence_flag" ); |
---|
| 634 | } |
---|
| 635 | |
---|
| 636 | WRITE_FLAG( sei.m_upsampledAspectRatio, "upsampled_aspect_ratio" ); |
---|
[1029] | 637 | } |
---|
[313] | 638 | |
---|
[1029] | 639 | Void SEIWriter::xWriteSEISegmentedRectFramePacking(const SEISegmentedRectFramePacking& sei) |
---|
| 640 | { |
---|
| 641 | WRITE_FLAG( sei.m_arrangementCancelFlag, "segmented_rect_frame_packing_arrangement_cancel_flag" ); |
---|
| 642 | if( sei.m_arrangementCancelFlag == 0 ) |
---|
| 643 | { |
---|
| 644 | WRITE_CODE( sei.m_contentInterpretationType, 2, "segmented_rect_content_interpretation_type" ); |
---|
| 645 | WRITE_FLAG( sei.m_arrangementPersistenceFlag, "segmented_rect_frame_packing_arrangement_persistence" ); |
---|
| 646 | } |
---|
[313] | 647 | } |
---|
| 648 | |
---|
| 649 | Void SEIWriter::xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei) |
---|
| 650 | { |
---|
| 651 | Int i; |
---|
| 652 | WRITE_UVLC( sei.m_toneMapId, "tone_map_id" ); |
---|
| 653 | WRITE_FLAG( sei.m_toneMapCancelFlag, "tone_map_cancel_flag" ); |
---|
[1029] | 654 | if( !sei.m_toneMapCancelFlag ) |
---|
[313] | 655 | { |
---|
| 656 | WRITE_FLAG( sei.m_toneMapPersistenceFlag, "tone_map_persistence_flag" ); |
---|
| 657 | WRITE_CODE( sei.m_codedDataBitDepth, 8, "coded_data_bit_depth" ); |
---|
| 658 | WRITE_CODE( sei.m_targetBitDepth, 8, "target_bit_depth" ); |
---|
| 659 | WRITE_UVLC( sei.m_modelId, "model_id" ); |
---|
| 660 | switch(sei.m_modelId) |
---|
| 661 | { |
---|
| 662 | case 0: |
---|
| 663 | { |
---|
| 664 | WRITE_CODE( sei.m_minValue, 32, "min_value" ); |
---|
| 665 | WRITE_CODE( sei.m_maxValue, 32, "max_value" ); |
---|
| 666 | break; |
---|
| 667 | } |
---|
| 668 | case 1: |
---|
| 669 | { |
---|
| 670 | WRITE_CODE( sei.m_sigmoidMidpoint, 32, "sigmoid_midpoint" ); |
---|
| 671 | WRITE_CODE( sei.m_sigmoidWidth, 32, "sigmoid_width" ); |
---|
| 672 | break; |
---|
| 673 | } |
---|
| 674 | case 2: |
---|
| 675 | { |
---|
| 676 | UInt num = 1u << sei.m_targetBitDepth; |
---|
| 677 | for(i = 0; i < num; i++) |
---|
| 678 | { |
---|
| 679 | WRITE_CODE( sei.m_startOfCodedInterval[i], (( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3, "start_of_coded_interval" ); |
---|
| 680 | } |
---|
| 681 | break; |
---|
| 682 | } |
---|
| 683 | case 3: |
---|
| 684 | { |
---|
| 685 | WRITE_CODE( sei.m_numPivots, 16, "num_pivots" ); |
---|
| 686 | for(i = 0; i < sei.m_numPivots; i++ ) |
---|
| 687 | { |
---|
| 688 | WRITE_CODE( sei.m_codedPivotValue[i], (( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3, "coded_pivot_value" ); |
---|
| 689 | WRITE_CODE( sei.m_targetPivotValue[i], (( sei.m_targetBitDepth + 7 ) >> 3 ) << 3, "target_pivot_value"); |
---|
| 690 | } |
---|
| 691 | break; |
---|
| 692 | } |
---|
| 693 | case 4: |
---|
| 694 | { |
---|
| 695 | WRITE_CODE( sei.m_cameraIsoSpeedIdc, 8, "camera_iso_speed_idc" ); |
---|
| 696 | if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO |
---|
| 697 | { |
---|
| 698 | WRITE_CODE( sei.m_cameraIsoSpeedValue, 32, "camera_iso_speed_value" ); |
---|
| 699 | } |
---|
[713] | 700 | WRITE_CODE( sei.m_exposureIndexIdc, 8, "exposure_index_idc" ); |
---|
| 701 | if( sei.m_exposureIndexIdc == 255) //Extended_ISO |
---|
| 702 | { |
---|
| 703 | WRITE_CODE( sei.m_exposureIndexValue, 32, "exposure_index_value" ); |
---|
| 704 | } |
---|
[313] | 705 | WRITE_FLAG( sei.m_exposureCompensationValueSignFlag, "exposure_compensation_value_sign_flag" ); |
---|
| 706 | WRITE_CODE( sei.m_exposureCompensationValueNumerator, 16, "exposure_compensation_value_numerator" ); |
---|
| 707 | WRITE_CODE( sei.m_exposureCompensationValueDenomIdc, 16, "exposure_compensation_value_denom_idc" ); |
---|
| 708 | WRITE_CODE( sei.m_refScreenLuminanceWhite, 32, "ref_screen_luminance_white" ); |
---|
| 709 | WRITE_CODE( sei.m_extendedRangeWhiteLevel, 32, "extended_range_white_level" ); |
---|
| 710 | WRITE_CODE( sei.m_nominalBlackLevelLumaCodeValue, 16, "nominal_black_level_luma_code_value" ); |
---|
| 711 | WRITE_CODE( sei.m_nominalWhiteLevelLumaCodeValue, 16, "nominal_white_level_luma_code_value" ); |
---|
| 712 | WRITE_CODE( sei.m_extendedWhiteLevelLumaCodeValue, 16, "extended_white_level_luma_code_value" ); |
---|
| 713 | break; |
---|
| 714 | } |
---|
| 715 | default: |
---|
| 716 | { |
---|
| 717 | assert(!"Undefined SEIToneMapModelId"); |
---|
| 718 | break; |
---|
| 719 | } |
---|
| 720 | }//switch m_modelId |
---|
| 721 | }//if(!sei.m_toneMapCancelFlag) |
---|
| 722 | } |
---|
[713] | 723 | |
---|
[313] | 724 | Void SEIWriter::xWriteSEIDisplayOrientation(const SEIDisplayOrientation &sei) |
---|
| 725 | { |
---|
| 726 | WRITE_FLAG( sei.cancelFlag, "display_orientation_cancel_flag" ); |
---|
| 727 | if( !sei.cancelFlag ) |
---|
| 728 | { |
---|
| 729 | WRITE_FLAG( sei.horFlip, "hor_flip" ); |
---|
| 730 | WRITE_FLAG( sei.verFlip, "ver_flip" ); |
---|
| 731 | WRITE_CODE( sei.anticlockwiseRotation, 16, "anticlockwise_rotation" ); |
---|
| 732 | WRITE_FLAG( sei.persistenceFlag, "display_orientation_persistence_flag" ); |
---|
| 733 | } |
---|
| 734 | } |
---|
| 735 | |
---|
| 736 | Void SEIWriter::xWriteSEITemporalLevel0Index(const SEITemporalLevel0Index &sei) |
---|
| 737 | { |
---|
| 738 | WRITE_CODE( sei.tl0Idx, 8 , "tl0_idx" ); |
---|
| 739 | WRITE_CODE( sei.rapIdx, 8 , "rap_idx" ); |
---|
| 740 | } |
---|
| 741 | |
---|
| 742 | Void SEIWriter::xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei) |
---|
| 743 | { |
---|
| 744 | WRITE_FLAG( sei.m_gdrForegroundFlag, "gdr_foreground_flag"); |
---|
| 745 | } |
---|
| 746 | |
---|
[1307] | 747 | Void SEIWriter::xWriteSEINoDisplay(const SEINoDisplay& /*sei*/) |
---|
[1029] | 748 | { |
---|
| 749 | } |
---|
| 750 | |
---|
[313] | 751 | Void SEIWriter::xWriteSEISOPDescription(const SEISOPDescription& sei) |
---|
| 752 | { |
---|
| 753 | WRITE_UVLC( sei.m_sopSeqParameterSetId, "sop_seq_parameter_set_id" ); |
---|
| 754 | WRITE_UVLC( sei.m_numPicsInSopMinus1, "num_pics_in_sop_minus1" ); |
---|
| 755 | for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++) |
---|
| 756 | { |
---|
| 757 | WRITE_CODE( sei.m_sopDescVclNaluType[i], 6, "sop_desc_vcl_nalu_type" ); |
---|
| 758 | WRITE_CODE( sei.m_sopDescTemporalId[i], 3, "sop_desc_temporal_id" ); |
---|
| 759 | if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP) |
---|
| 760 | { |
---|
| 761 | WRITE_UVLC( sei.m_sopDescStRpsIdx[i], "sop_desc_st_rps_idx" ); |
---|
| 762 | } |
---|
| 763 | if (i > 0) |
---|
| 764 | { |
---|
| 765 | WRITE_SVLC( sei.m_sopDescPocDelta[i], "sop_desc_poc_delta" ); |
---|
| 766 | } |
---|
| 767 | } |
---|
| 768 | } |
---|
| 769 | |
---|
[644] | 770 | #if O0164_MULTI_LAYER_HRD |
---|
[1235] | 771 | Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, const TComVPS *vps, const TComSPS *sps) |
---|
[644] | 772 | #else |
---|
[1235] | 773 | Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, const TComSPS *sps) |
---|
[644] | 774 | #endif |
---|
[595] | 775 | { |
---|
| 776 | WRITE_FLAG( sei.m_bitStreamSubsetFlag, "bitstream_subset_flag" ); |
---|
| 777 | WRITE_FLAG( sei.m_nestingOpFlag, "nesting_op_flag " ); |
---|
| 778 | if (sei.m_nestingOpFlag) |
---|
| 779 | { |
---|
| 780 | WRITE_FLAG( sei.m_defaultOpFlag, "default_op_flag" ); |
---|
[894] | 781 | WRITE_UVLC( sei.m_nestingNumOpsMinus1, "nesting_num_ops_minus1" ); |
---|
[595] | 782 | for (UInt i = (sei.m_defaultOpFlag ? 1 : 0); i <= sei.m_nestingNumOpsMinus1; i++) |
---|
| 783 | { |
---|
[894] | 784 | WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3, "nesting_max_temporal_id_plus1" ); |
---|
[595] | 785 | WRITE_UVLC( sei.m_nestingOpIdx[i], "nesting_op_idx" ); |
---|
| 786 | } |
---|
| 787 | } |
---|
| 788 | else |
---|
| 789 | { |
---|
| 790 | WRITE_FLAG( sei.m_allLayersFlag, "all_layers_flag" ); |
---|
| 791 | if (!sei.m_allLayersFlag) |
---|
| 792 | { |
---|
[894] | 793 | WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id_plus1" ); |
---|
| 794 | WRITE_UVLC( sei.m_nestingNumLayersMinus1, "nesting_num_layers" ); |
---|
[595] | 795 | for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++) |
---|
| 796 | { |
---|
| 797 | WRITE_CODE( sei.m_nestingLayerId[i], 6, "nesting_layer_id" ); |
---|
| 798 | } |
---|
| 799 | } |
---|
| 800 | } |
---|
[1029] | 801 | |
---|
[595] | 802 | // byte alignment |
---|
| 803 | while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) |
---|
| 804 | { |
---|
| 805 | WRITE_FLAG( 0, "nesting_zero_bit" ); |
---|
| 806 | } |
---|
| 807 | |
---|
| 808 | // write nested SEI messages |
---|
[1352] | 809 | #if O0164_MULTI_LAYER_HRD |
---|
| 810 | writeSEImessages(bs, sei.m_nestedSEIs, vps, sps, true, &sei); |
---|
[644] | 811 | #else |
---|
[1352] | 812 | writeSEImessages(bs, sei.m_nestedSEIs, sps, true); |
---|
[644] | 813 | #endif |
---|
[595] | 814 | } |
---|
| 815 | |
---|
[1307] | 816 | Void SEIWriter::xWriteSEITempMotionConstrainedTileSets(const SEITempMotionConstrainedTileSets& sei) |
---|
[1029] | 817 | { |
---|
| 818 | //UInt code; |
---|
| 819 | WRITE_FLAG((sei.m_mc_all_tiles_exact_sample_value_match_flag ? 1 : 0), "mc_all_tiles_exact_sample_value_match_flag"); |
---|
| 820 | WRITE_FLAG((sei.m_each_tile_one_tile_set_flag ? 1 : 0), "each_tile_one_tile_set_flag" ); |
---|
| 821 | |
---|
| 822 | if(!sei.m_each_tile_one_tile_set_flag) |
---|
| 823 | { |
---|
| 824 | WRITE_FLAG((sei.m_limited_tile_set_display_flag ? 1 : 0), "limited_tile_set_display_flag"); |
---|
| 825 | WRITE_UVLC((sei.getNumberOfTileSets() - 1), "num_sets_in_message_minus1" ); |
---|
| 826 | |
---|
| 827 | if(sei.getNumberOfTileSets() > 0) |
---|
| 828 | { |
---|
| 829 | for(Int i = 0; i < sei.getNumberOfTileSets(); i++) |
---|
| 830 | { |
---|
| 831 | WRITE_UVLC(sei.tileSetData(i).m_mcts_id, "mcts_id"); |
---|
| 832 | |
---|
| 833 | if(sei.m_limited_tile_set_display_flag) |
---|
| 834 | { |
---|
| 835 | WRITE_FLAG((sei.tileSetData(i).m_display_tile_set_flag ? 1 : 0), "display_tile_set_flag"); |
---|
| 836 | } |
---|
| 837 | |
---|
| 838 | WRITE_UVLC((sei.tileSetData(i).getNumberOfTileRects() - 1), "num_tile_rects_in_set_minus1"); |
---|
| 839 | |
---|
| 840 | for(Int j = 0; j < sei.tileSetData(i).getNumberOfTileRects(); j++) |
---|
| 841 | { |
---|
| 842 | WRITE_UVLC(sei.tileSetData(i).topLeftTileIndex (j), "top_left_tile_index"); |
---|
| 843 | WRITE_UVLC(sei.tileSetData(i).bottomRightTileIndex(j), "bottom_right_tile_index"); |
---|
| 844 | } |
---|
| 845 | |
---|
| 846 | if(!sei.m_mc_all_tiles_exact_sample_value_match_flag) |
---|
| 847 | { |
---|
| 848 | WRITE_FLAG((sei.tileSetData(i).m_exact_sample_value_match_flag ? 1 : 0), "exact_sample_value_match_flag"); |
---|
| 849 | } |
---|
| 850 | |
---|
| 851 | WRITE_FLAG((sei.tileSetData(i).m_mcts_tier_level_idc_present_flag ? 1 : 0), "mcts_tier_level_idc_present_flag"); |
---|
| 852 | |
---|
| 853 | if(sei.tileSetData(i).m_mcts_tier_level_idc_present_flag) |
---|
| 854 | { |
---|
| 855 | WRITE_FLAG((sei.tileSetData(i).m_mcts_tier_flag ? 1 : 0), "mcts_tier_flag"); |
---|
| 856 | WRITE_CODE( sei.tileSetData(i).m_mcts_level_idc, 8, "mcts_level_idc"); |
---|
| 857 | } |
---|
| 858 | } |
---|
| 859 | } |
---|
| 860 | } |
---|
| 861 | else |
---|
| 862 | { |
---|
| 863 | WRITE_FLAG((sei.m_max_mcs_tier_level_idc_present_flag ? 1 : 0), "max_mcs_tier_level_idc_present_flag"); |
---|
| 864 | |
---|
| 865 | if(sei.m_max_mcs_tier_level_idc_present_flag) |
---|
| 866 | { |
---|
| 867 | WRITE_FLAG((sei.m_max_mcts_tier_flag ? 1 : 0), "max_mcts_tier_flag"); |
---|
| 868 | WRITE_CODE( sei.m_max_mcts_level_idc, 8, "max_mcts_level_idc"); |
---|
| 869 | } |
---|
| 870 | } |
---|
| 871 | } |
---|
| 872 | |
---|
| 873 | Void SEIWriter::xWriteSEITimeCode(const SEITimeCode& sei) |
---|
| 874 | { |
---|
| 875 | WRITE_CODE(sei.numClockTs, 2, "num_clock_ts"); |
---|
| 876 | for(Int i = 0; i < sei.numClockTs; i++) |
---|
| 877 | { |
---|
| 878 | const TComSEITimeSet ¤tTimeSet = sei.timeSetArray[i]; |
---|
| 879 | WRITE_FLAG(currentTimeSet.clockTimeStampFlag, "clock_time_stamp_flag"); |
---|
| 880 | if(currentTimeSet.clockTimeStampFlag) |
---|
| 881 | { |
---|
| 882 | WRITE_FLAG(currentTimeSet.numUnitFieldBasedFlag, "units_field_based_flag"); |
---|
| 883 | WRITE_CODE(currentTimeSet.countingType, 5, "counting_type"); |
---|
| 884 | WRITE_FLAG(currentTimeSet.fullTimeStampFlag, "full_timestamp_flag"); |
---|
| 885 | WRITE_FLAG(currentTimeSet.discontinuityFlag, "discontinuity_flag"); |
---|
| 886 | WRITE_FLAG(currentTimeSet.cntDroppedFlag, "cnt_dropped_flag"); |
---|
| 887 | WRITE_CODE(currentTimeSet.numberOfFrames, 9, "n_frames"); |
---|
| 888 | if(currentTimeSet.fullTimeStampFlag) |
---|
| 889 | { |
---|
| 890 | WRITE_CODE(currentTimeSet.secondsValue, 6, "seconds_value"); |
---|
| 891 | WRITE_CODE(currentTimeSet.minutesValue, 6, "minutes_value"); |
---|
| 892 | WRITE_CODE(currentTimeSet.hoursValue, 5, "hours_value"); |
---|
| 893 | } |
---|
| 894 | else |
---|
| 895 | { |
---|
| 896 | WRITE_FLAG(currentTimeSet.secondsFlag, "seconds_flag"); |
---|
| 897 | if(currentTimeSet.secondsFlag) |
---|
| 898 | { |
---|
| 899 | WRITE_CODE(currentTimeSet.secondsValue, 6, "seconds_value"); |
---|
| 900 | WRITE_FLAG(currentTimeSet.minutesFlag, "minutes_flag"); |
---|
| 901 | if(currentTimeSet.minutesFlag) |
---|
| 902 | { |
---|
| 903 | WRITE_CODE(currentTimeSet.minutesValue, 6, "minutes_value"); |
---|
| 904 | WRITE_FLAG(currentTimeSet.hoursFlag, "hours_flag"); |
---|
| 905 | if(currentTimeSet.hoursFlag) |
---|
[1246] | 906 | { |
---|
[1029] | 907 | WRITE_CODE(currentTimeSet.hoursValue, 5, "hours_value"); |
---|
[1246] | 908 | } |
---|
[1029] | 909 | } |
---|
| 910 | } |
---|
| 911 | } |
---|
| 912 | WRITE_CODE(currentTimeSet.timeOffsetLength, 5, "time_offset_length"); |
---|
| 913 | if(currentTimeSet.timeOffsetLength > 0) |
---|
| 914 | { |
---|
| 915 | if(currentTimeSet.timeOffsetValue >= 0) |
---|
| 916 | { |
---|
| 917 | WRITE_CODE((UInt)currentTimeSet.timeOffsetValue, currentTimeSet.timeOffsetLength, "time_offset_value"); |
---|
| 918 | } |
---|
| 919 | else |
---|
| 920 | { |
---|
| 921 | // Two's complement conversion |
---|
| 922 | UInt offsetValue = ~(currentTimeSet.timeOffsetValue) + 1; |
---|
| 923 | offsetValue |= (1 << (currentTimeSet.timeOffsetLength-1)); |
---|
| 924 | WRITE_CODE(offsetValue, currentTimeSet.timeOffsetLength, "time_offset_value"); |
---|
| 925 | } |
---|
| 926 | } |
---|
| 927 | } |
---|
| 928 | } |
---|
| 929 | } |
---|
| 930 | |
---|
[1434] | 931 | Void SEIWriter::xWriteSEIChromaResamplingFilterHint(const SEIChromaResamplingFilterHint &sei) |
---|
[1029] | 932 | { |
---|
| 933 | WRITE_CODE(sei.m_verChromaFilterIdc, 8, "ver_chroma_filter_idc"); |
---|
| 934 | WRITE_CODE(sei.m_horChromaFilterIdc, 8, "hor_chroma_filter_idc"); |
---|
[1434] | 935 | WRITE_FLAG(sei.m_verFilteringFieldProcessingFlag, "ver_filtering_field_processing_flag"); |
---|
[1029] | 936 | if(sei.m_verChromaFilterIdc == 1 || sei.m_horChromaFilterIdc == 1) |
---|
| 937 | { |
---|
[1434] | 938 | WRITE_UVLC(sei.m_targetFormatIdc, "target_format_idc"); |
---|
| 939 | if(sei.m_verChromaFilterIdc == 1) |
---|
[1029] | 940 | { |
---|
[1434] | 941 | const Int numVerticalFilter = (Int)sei.m_verFilterCoeff.size(); |
---|
| 942 | WRITE_UVLC(numVerticalFilter, "num_vertical_filters"); |
---|
| 943 | if(numVerticalFilter > 0) |
---|
[1029] | 944 | { |
---|
[1434] | 945 | for(Int i = 0; i < numVerticalFilter; i ++) |
---|
[1029] | 946 | { |
---|
[1434] | 947 | const Int verTapLengthMinus1 = (Int) sei.m_verFilterCoeff[i].size() - 1; |
---|
| 948 | WRITE_UVLC(verTapLengthMinus1, "ver_tap_length_minus_1"); |
---|
| 949 | for(Int j = 0; j < (verTapLengthMinus1 + 1); j ++) |
---|
| 950 | { |
---|
| 951 | WRITE_SVLC(sei.m_verFilterCoeff[i][j], "ver_filter_coeff"); |
---|
| 952 | } |
---|
[1029] | 953 | } |
---|
| 954 | } |
---|
| 955 | } |
---|
[1434] | 956 | if(sei.m_horChromaFilterIdc == 1) |
---|
[1029] | 957 | { |
---|
[1434] | 958 | const Int numHorizontalFilter = (Int) sei.m_horFilterCoeff.size(); |
---|
| 959 | WRITE_UVLC(numHorizontalFilter, "num_horizontal_filters"); |
---|
| 960 | if(numHorizontalFilter > 0) |
---|
[1029] | 961 | { |
---|
[1434] | 962 | for(Int i = 0; i < numHorizontalFilter; i ++) |
---|
[1029] | 963 | { |
---|
[1434] | 964 | const Int horTapLengthMinus1 = (Int) sei.m_horFilterCoeff[i].size() - 1; |
---|
| 965 | WRITE_UVLC(horTapLengthMinus1, "hor_tap_length_minus_1"); |
---|
| 966 | for(Int j = 0; j < (horTapLengthMinus1 + 1); j ++) |
---|
| 967 | { |
---|
| 968 | WRITE_SVLC(sei.m_horFilterCoeff[i][j], "hor_filter_coeff"); |
---|
| 969 | } |
---|
[1029] | 970 | } |
---|
| 971 | } |
---|
| 972 | } |
---|
| 973 | } |
---|
| 974 | } |
---|
| 975 | |
---|
| 976 | Void SEIWriter::xWriteSEIKneeFunctionInfo(const SEIKneeFunctionInfo &sei) |
---|
| 977 | { |
---|
| 978 | WRITE_UVLC( sei.m_kneeId, "knee_function_id" ); |
---|
| 979 | WRITE_FLAG( sei.m_kneeCancelFlag, "knee_function_cancel_flag" ); |
---|
| 980 | if ( !sei.m_kneeCancelFlag ) |
---|
| 981 | { |
---|
| 982 | WRITE_FLAG( sei.m_kneePersistenceFlag, "knee_function_persistence_flag" ); |
---|
| 983 | WRITE_CODE( (UInt)sei.m_kneeInputDrange , 32, "input_d_range" ); |
---|
| 984 | WRITE_CODE( (UInt)sei.m_kneeInputDispLuminance, 32, "input_disp_luminance" ); |
---|
| 985 | WRITE_CODE( (UInt)sei.m_kneeOutputDrange, 32, "output_d_range" ); |
---|
| 986 | WRITE_CODE( (UInt)sei.m_kneeOutputDispLuminance, 32, "output_disp_luminance" ); |
---|
| 987 | WRITE_UVLC( sei.m_kneeNumKneePointsMinus1, "num_knee_points_minus1" ); |
---|
| 988 | for(Int i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ ) |
---|
| 989 | { |
---|
| 990 | WRITE_CODE( (UInt)sei.m_kneeInputKneePoint[i], 10,"input_knee_point" ); |
---|
| 991 | WRITE_CODE( (UInt)sei.m_kneeOutputKneePoint[i], 10, "output_knee_point" ); |
---|
| 992 | } |
---|
| 993 | } |
---|
| 994 | } |
---|
| 995 | |
---|
[1460] | 996 | Void SEIWriter::xWriteSEIColourRemappingInfo(const SEIColourRemappingInfo& sei) |
---|
| 997 | { |
---|
| 998 | WRITE_UVLC( sei.m_colourRemapId, "colour_remap_id" ); |
---|
| 999 | WRITE_FLAG( sei.m_colourRemapCancelFlag, "colour_remap_cancel_flag" ); |
---|
| 1000 | if( !sei.m_colourRemapCancelFlag ) |
---|
| 1001 | { |
---|
| 1002 | WRITE_FLAG( sei.m_colourRemapPersistenceFlag, "colour_remap_persistence_flag" ); |
---|
| 1003 | WRITE_FLAG( sei.m_colourRemapVideoSignalInfoPresentFlag, "colour_remap_video_signal_info_present_flag" ); |
---|
| 1004 | if ( sei.m_colourRemapVideoSignalInfoPresentFlag ) |
---|
| 1005 | { |
---|
| 1006 | WRITE_FLAG( sei.m_colourRemapFullRangeFlag, "colour_remap_full_range_flag" ); |
---|
| 1007 | WRITE_CODE( sei.m_colourRemapPrimaries, 8, "colour_remap_primaries" ); |
---|
| 1008 | WRITE_CODE( sei.m_colourRemapTransferFunction, 8, "colour_remap_transfer_function" ); |
---|
| 1009 | WRITE_CODE( sei.m_colourRemapMatrixCoefficients, 8, "colour_remap_matrix_coefficients" ); |
---|
| 1010 | } |
---|
| 1011 | WRITE_CODE( sei.m_colourRemapInputBitDepth, 8, "colour_remap_input_bit_depth" ); |
---|
| 1012 | WRITE_CODE( sei.m_colourRemapBitDepth, 8, "colour_remap_bit_depth" ); |
---|
| 1013 | for( Int c=0 ; c<3 ; c++ ) |
---|
| 1014 | { |
---|
| 1015 | WRITE_CODE( sei.m_preLutNumValMinus1[c], 8, "pre_lut_num_val_minus1[c]" ); |
---|
| 1016 | if( sei.m_preLutNumValMinus1[c]>0 ) |
---|
| 1017 | { |
---|
| 1018 | for( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ ) |
---|
| 1019 | { |
---|
| 1020 | WRITE_CODE( sei.m_preLut[c][i].codedValue, (( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, "pre_lut_coded_value[c][i]" ); |
---|
| 1021 | WRITE_CODE( sei.m_preLut[c][i].targetValue, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "pre_lut_target_value[c][i]" ); |
---|
| 1022 | } |
---|
| 1023 | } |
---|
| 1024 | } |
---|
| 1025 | WRITE_FLAG( sei.m_colourRemapMatrixPresentFlag, "colour_remap_matrix_present_flag" ); |
---|
| 1026 | if( sei.m_colourRemapMatrixPresentFlag ) |
---|
| 1027 | { |
---|
| 1028 | WRITE_CODE( sei.m_log2MatrixDenom, 4, "log2_matrix_denom" ); |
---|
| 1029 | for( Int c=0 ; c<3 ; c++ ) |
---|
| 1030 | { |
---|
| 1031 | for( Int i=0 ; i<3 ; i++ ) |
---|
| 1032 | { |
---|
| 1033 | WRITE_SVLC( sei.m_colourRemapCoeffs[c][i], "colour_remap_coeffs[c][i]" ); |
---|
| 1034 | } |
---|
| 1035 | } |
---|
| 1036 | } |
---|
[1029] | 1037 | |
---|
[1460] | 1038 | for( Int c=0 ; c<3 ; c++ ) |
---|
| 1039 | { |
---|
| 1040 | WRITE_CODE( sei.m_postLutNumValMinus1[c], 8, "m_postLutNumValMinus1[c]" ); |
---|
| 1041 | if( sei.m_postLutNumValMinus1[c]>0 ) |
---|
| 1042 | { |
---|
| 1043 | for( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ ) |
---|
| 1044 | { |
---|
| 1045 | WRITE_CODE( sei.m_postLut[c][i].codedValue, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "post_lut_coded_value[c][i]" ); |
---|
| 1046 | WRITE_CODE( sei.m_postLut[c][i].targetValue, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "post_lut_target_value[c][i]" ); |
---|
| 1047 | } |
---|
| 1048 | } |
---|
| 1049 | } |
---|
| 1050 | } |
---|
| 1051 | } |
---|
| 1052 | |
---|
[1029] | 1053 | Void SEIWriter::xWriteSEIMasteringDisplayColourVolume(const SEIMasteringDisplayColourVolume& sei) |
---|
| 1054 | { |
---|
| 1055 | WRITE_CODE( sei.values.primaries[0][0], 16, "display_primaries_x[0]" ); |
---|
| 1056 | WRITE_CODE( sei.values.primaries[0][1], 16, "display_primaries_y[0]" ); |
---|
| 1057 | |
---|
| 1058 | WRITE_CODE( sei.values.primaries[1][0], 16, "display_primaries_x[1]" ); |
---|
| 1059 | WRITE_CODE( sei.values.primaries[1][1], 16, "display_primaries_y[1]" ); |
---|
| 1060 | |
---|
| 1061 | WRITE_CODE( sei.values.primaries[2][0], 16, "display_primaries_x[2]" ); |
---|
| 1062 | WRITE_CODE( sei.values.primaries[2][1], 16, "display_primaries_y[2]" ); |
---|
| 1063 | |
---|
| 1064 | WRITE_CODE( sei.values.whitePoint[0], 16, "white_point_x" ); |
---|
| 1065 | WRITE_CODE( sei.values.whitePoint[1], 16, "white_point_y" ); |
---|
| 1066 | |
---|
| 1067 | WRITE_CODE( sei.values.maxLuminance, 32, "max_display_mastering_luminance" ); |
---|
| 1068 | WRITE_CODE( sei.values.minLuminance, 32, "min_display_mastering_luminance" ); |
---|
| 1069 | } |
---|
| 1070 | |
---|
| 1071 | |
---|
[595] | 1072 | Void SEIWriter::xWriteByteAlign() |
---|
| 1073 | { |
---|
| 1074 | if( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0) |
---|
| 1075 | { |
---|
[1029] | 1076 | WRITE_FLAG( 1, "payload_bit_equal_to_one" ); |
---|
[595] | 1077 | while( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) |
---|
| 1078 | { |
---|
[1029] | 1079 | WRITE_FLAG( 0, "payload_bit_equal_to_zero" ); |
---|
[595] | 1080 | } |
---|
| 1081 | } |
---|
[1029] | 1082 | } |
---|
[595] | 1083 | |
---|
[1538] | 1084 | #if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI |
---|
| 1085 | Void SEIWriter::xWriteSEIAlternativeTransferCharacteristics(const SEIAlternativeTransferCharacteristics& sei) |
---|
| 1086 | { |
---|
| 1087 | WRITE_CODE(sei.m_preferredTransferCharacteristics, 8, "preferred_transfer_characteristics"); |
---|
| 1088 | } |
---|
| 1089 | #endif |
---|
| 1090 | |
---|
[1572] | 1091 | Void SEIWriter::xWriteSEIGreenMetadataInfo(const SEIGreenMetadataInfo& sei) |
---|
| 1092 | { |
---|
| 1093 | WRITE_CODE(sei.m_greenMetadataType, 8, "green_metadata_type"); |
---|
| 1094 | |
---|
| 1095 | WRITE_CODE(sei.m_xsdMetricType, 8, "xsd_metric_type"); |
---|
| 1096 | WRITE_CODE(sei.m_xsdMetricValue, 16, "xsd_metric_value"); |
---|
| 1097 | } |
---|
| 1098 | |
---|
[595] | 1099 | #if SVC_EXTENSION |
---|
| 1100 | #if LAYERS_NOT_PRESENT_SEI |
---|
| 1101 | Void SEIWriter::xWriteSEILayersNotPresent(const SEILayersNotPresent& sei) |
---|
| 1102 | { |
---|
| 1103 | WRITE_UVLC( sei.m_activeVpsId, "lp_sei_active_vps_id" ); |
---|
| 1104 | for (UInt i = 0; i < sei.m_vpsMaxLayers; i++) |
---|
| 1105 | { |
---|
| 1106 | WRITE_FLAG( sei.m_layerNotPresentFlag[i], "layer_not_present_flag" ); |
---|
[1029] | 1107 | } |
---|
[595] | 1108 | } |
---|
| 1109 | #endif |
---|
| 1110 | |
---|
[442] | 1111 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
| 1112 | Void SEIWriter::xWriteSEIInterLayerConstrainedTileSets(const SEIInterLayerConstrainedTileSets& sei) |
---|
| 1113 | { |
---|
| 1114 | WRITE_FLAG( sei.m_ilAllTilesExactSampleValueMatchFlag, "il_all_tiles_exact_sample_value_match_flag" ); |
---|
| 1115 | WRITE_FLAG( sei.m_ilOneTilePerTileSetFlag, "il_one_tile_per_tile_set_flag" ); |
---|
| 1116 | if( !sei.m_ilOneTilePerTileSetFlag ) |
---|
| 1117 | { |
---|
| 1118 | WRITE_UVLC( sei.m_ilNumSetsInMessageMinus1, "il_num_sets_in_message_minus1" ); |
---|
| 1119 | if( sei.m_ilNumSetsInMessageMinus1 ) |
---|
| 1120 | { |
---|
| 1121 | WRITE_FLAG( sei.m_skippedTileSetPresentFlag, "skipped_tile_set_present_flag" ); |
---|
| 1122 | } |
---|
| 1123 | UInt numSignificantSets = sei.m_ilNumSetsInMessageMinus1 - (sei.m_skippedTileSetPresentFlag ? 1 : 0) + 1; |
---|
| 1124 | for( UInt i = 0; i < numSignificantSets; i++ ) |
---|
| 1125 | { |
---|
| 1126 | WRITE_UVLC( sei.m_ilctsId[i], "ilcts_id" ); |
---|
| 1127 | WRITE_UVLC( sei.m_ilNumTileRectsInSetMinus1[i], "il_num_tile_rects_in_set_minus1" ); |
---|
| 1128 | for( UInt j = 0; j <= sei.m_ilNumTileRectsInSetMinus1[i]; j++ ) |
---|
| 1129 | { |
---|
| 1130 | WRITE_UVLC( sei.m_ilTopLeftTileIndex[i][j], "il_top_left_tile_index" ); |
---|
| 1131 | WRITE_UVLC( sei.m_ilBottomRightTileIndex[i][j], "il_bottom_right_tile_index" ); |
---|
| 1132 | } |
---|
| 1133 | WRITE_CODE( sei.m_ilcIdc[i], 2, "ilc_idc" ); |
---|
| 1134 | if( sei.m_ilAllTilesExactSampleValueMatchFlag ) |
---|
| 1135 | { |
---|
| 1136 | WRITE_FLAG( sei.m_ilExactSampleValueMatchFlag[i], "il_exact_sample_value_match_flag" ); |
---|
| 1137 | } |
---|
| 1138 | } |
---|
| 1139 | } |
---|
| 1140 | else |
---|
| 1141 | { |
---|
| 1142 | WRITE_CODE( sei.m_allTilesIlcIdc, 2, "all_tiles_ilc_idc" ); |
---|
| 1143 | } |
---|
| 1144 | } |
---|
| 1145 | #endif |
---|
[588] | 1146 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
| 1147 | Void SEIWriter::xWriteSEISubBitstreamProperty(const SEISubBitstreamProperty &sei) |
---|
| 1148 | { |
---|
| 1149 | WRITE_CODE( sei.m_activeVpsId, 4, "active_vps_id" ); |
---|
| 1150 | assert( sei.m_numAdditionalSubStreams >= 1 ); |
---|
| 1151 | WRITE_UVLC( sei.m_numAdditionalSubStreams - 1, "num_additional_sub_streams_minus1" ); |
---|
[442] | 1152 | |
---|
[588] | 1153 | for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ ) |
---|
| 1154 | { |
---|
| 1155 | WRITE_CODE( sei.m_subBitstreamMode[i], 2, "sub_bitstream_mode[i]" ); |
---|
| 1156 | WRITE_UVLC( sei.m_outputLayerSetIdxToVps[i], "output_layer_set_idx_to_vps[i]" ); |
---|
| 1157 | WRITE_CODE( sei.m_highestSublayerId[i], 3, "highest_sub_layer_id[i]" ); |
---|
| 1158 | WRITE_CODE( sei.m_avgBitRate[i], 16, "avg_bit_rate[i]" ); |
---|
| 1159 | WRITE_CODE( sei.m_maxBitRate[i], 16, "max_bit_rate[i]" ); |
---|
[1029] | 1160 | } |
---|
[588] | 1161 | } |
---|
| 1162 | #endif |
---|
[644] | 1163 | |
---|
[815] | 1164 | #if Q0189_TMVP_CONSTRAINTS |
---|
| 1165 | Void SEIWriter::xWriteSEITMVPConstraints (const SEITMVPConstrains &sei) |
---|
| 1166 | { |
---|
| 1167 | WRITE_UVLC( sei.prev_pics_not_used_flag , "prev_pics_not_used_flag" ); |
---|
| 1168 | WRITE_UVLC( sei.no_intra_layer_col_pic_flag , "no_intra_layer_col_pic_flag" ); |
---|
| 1169 | } |
---|
| 1170 | #endif |
---|
| 1171 | |
---|
| 1172 | #if Q0247_FRAME_FIELD_INFO |
---|
| 1173 | Void SEIWriter::xWriteSEIFrameFieldInfo (const SEIFrameFieldInfo &sei) |
---|
| 1174 | { |
---|
| 1175 | WRITE_CODE( sei.m_ffinfo_picStruct , 4, "ffinfo_pic_struct" ); |
---|
| 1176 | WRITE_CODE( sei.m_ffinfo_sourceScanType, 2, "ffinfo_source_scan_type" ); |
---|
| 1177 | WRITE_FLAG( sei.m_ffinfo_duplicateFlag ? 1 : 0, "ffinfo_duplicate_flag" ); |
---|
| 1178 | } |
---|
| 1179 | #endif |
---|
| 1180 | |
---|
[644] | 1181 | #if O0164_MULTI_LAYER_HRD |
---|
[1235] | 1182 | Void SEIWriter::xWriteSEIBspNesting(TComBitIf& bs, const SEIBspNesting &sei, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting &nestingSei) |
---|
[644] | 1183 | { |
---|
| 1184 | WRITE_UVLC( sei.m_bspIdx, "bsp_idx" ); |
---|
| 1185 | |
---|
| 1186 | while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) |
---|
| 1187 | { |
---|
| 1188 | WRITE_FLAG( 0, "bsp_nesting_zero_bit" ); |
---|
| 1189 | } |
---|
[1134] | 1190 | |
---|
[847] | 1191 | assert( sei.m_nestedSEIs.size() <= MAX_SEIS_IN_BSP_NESTING ); |
---|
[1077] | 1192 | WRITE_UVLC( (UInt)sei.m_nestedSEIs.size(), "num_seis_in_bsp_minus1" ); |
---|
[1273] | 1193 | |
---|
[644] | 1194 | // write nested SEI messages |
---|
[1352] | 1195 | writeSEImessages(bs, sei.m_nestedSEIs, vps, sps, true, &nestingSei, &sei); |
---|
[644] | 1196 | } |
---|
| 1197 | |
---|
[1235] | 1198 | Void SEIWriter::xWriteSEIBspInitialArrivalTime(const SEIBspInitialArrivalTime &sei, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei) |
---|
[644] | 1199 | { |
---|
| 1200 | assert(vps->getVpsVuiPresentFlag()); |
---|
| 1201 | |
---|
[894] | 1202 | Int psIdx = bspNestingSei.m_seiPartitioningSchemeIdx; |
---|
| 1203 | Int seiOlsIdx = bspNestingSei.m_seiOlsIdx; |
---|
| 1204 | Int maxTemporalId = nestingSei.m_nestingMaxTemporalIdPlus1[0] - 1; |
---|
| 1205 | Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; |
---|
| 1206 | std::vector<Int> hrdIdx(maxValues, 0); |
---|
[1235] | 1207 | std::vector<const TComHRD*> hrdVec; |
---|
[894] | 1208 | std::vector<Int> syntaxElemLen(maxValues, 0); |
---|
| 1209 | for(Int i = 0; i < maxValues; i++) |
---|
| 1210 | { |
---|
| 1211 | hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei.m_bspIdx); |
---|
| 1212 | hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); |
---|
| 1213 | |
---|
| 1214 | syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
| 1215 | if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) |
---|
| 1216 | { |
---|
| 1217 | assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 |
---|
| 1218 | } |
---|
| 1219 | if( i > 0 ) |
---|
| 1220 | { |
---|
| 1221 | assert( hrdVec[i]->getNalHrdParametersPresentFlag() == hrdVec[i-1]->getNalHrdParametersPresentFlag() ); |
---|
| 1222 | assert( hrdVec[i]->getVclHrdParametersPresentFlag() == hrdVec[i-1]->getVclHrdParametersPresentFlag() ); |
---|
| 1223 | } |
---|
| 1224 | } |
---|
| 1225 | if (hrdVec[0]->getNalHrdParametersPresentFlag()) |
---|
| 1226 | { |
---|
| 1227 | for(UInt i = 0; i < maxValues; i++) |
---|
| 1228 | { |
---|
| 1229 | WRITE_CODE( sei.m_nalInitialArrivalDelay[i], syntaxElemLen[i], "nal_initial_arrival_delay[i]" ); |
---|
| 1230 | } |
---|
| 1231 | } |
---|
| 1232 | if( hrdVec[0]->getVclHrdParametersPresentFlag() ) |
---|
| 1233 | { |
---|
| 1234 | for(UInt i = 0; i < maxValues; i++) |
---|
| 1235 | { |
---|
| 1236 | WRITE_CODE( sei.m_vclInitialArrivalDelay[i], syntaxElemLen[i], "vcl_initial_arrival_delay[i]" ); |
---|
| 1237 | } |
---|
| 1238 | } |
---|
[644] | 1239 | } |
---|
| 1240 | |
---|
| 1241 | Void SEIWriter::xCodeHrdParameters( TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 ) |
---|
| 1242 | { |
---|
| 1243 | if( commonInfPresentFlag ) |
---|
| 1244 | { |
---|
| 1245 | WRITE_FLAG( hrd->getNalHrdParametersPresentFlag() ? 1 : 0 , "nal_hrd_parameters_present_flag" ); |
---|
| 1246 | WRITE_FLAG( hrd->getVclHrdParametersPresentFlag() ? 1 : 0 , "vcl_hrd_parameters_present_flag" ); |
---|
| 1247 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
| 1248 | { |
---|
| 1249 | WRITE_FLAG( hrd->getSubPicCpbParamsPresentFlag() ? 1 : 0, "sub_pic_cpb_params_present_flag" ); |
---|
| 1250 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 1251 | { |
---|
| 1252 | WRITE_CODE( hrd->getTickDivisorMinus2(), 8, "tick_divisor_minus2" ); |
---|
| 1253 | WRITE_CODE( hrd->getDuCpbRemovalDelayLengthMinus1(), 5, "du_cpb_removal_delay_length_minus1" ); |
---|
| 1254 | WRITE_FLAG( hrd->getSubPicCpbParamsInPicTimingSEIFlag() ? 1 : 0, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); |
---|
| 1255 | WRITE_CODE( hrd->getDpbOutputDelayDuLengthMinus1(), 5, "dpb_output_delay_du_length_minus1" ); |
---|
| 1256 | } |
---|
| 1257 | WRITE_CODE( hrd->getBitRateScale(), 4, "bit_rate_scale" ); |
---|
| 1258 | WRITE_CODE( hrd->getCpbSizeScale(), 4, "cpb_size_scale" ); |
---|
| 1259 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 1260 | { |
---|
| 1261 | WRITE_CODE( hrd->getDuCpbSizeScale(), 4, "du_cpb_size_scale" ); |
---|
| 1262 | } |
---|
| 1263 | WRITE_CODE( hrd->getInitialCpbRemovalDelayLengthMinus1(), 5, "initial_cpb_removal_delay_length_minus1" ); |
---|
| 1264 | WRITE_CODE( hrd->getCpbRemovalDelayLengthMinus1(), 5, "au_cpb_removal_delay_length_minus1" ); |
---|
| 1265 | WRITE_CODE( hrd->getDpbOutputDelayLengthMinus1(), 5, "dpb_output_delay_length_minus1" ); |
---|
| 1266 | } |
---|
| 1267 | } |
---|
| 1268 | Int i, j, nalOrVcl; |
---|
| 1269 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
| 1270 | { |
---|
| 1271 | WRITE_FLAG( hrd->getFixedPicRateFlag( i ) ? 1 : 0, "fixed_pic_rate_general_flag"); |
---|
| 1272 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
| 1273 | { |
---|
| 1274 | WRITE_FLAG( hrd->getFixedPicRateWithinCvsFlag( i ) ? 1 : 0, "fixed_pic_rate_within_cvs_flag"); |
---|
| 1275 | } |
---|
| 1276 | else |
---|
| 1277 | { |
---|
| 1278 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
| 1279 | } |
---|
| 1280 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
| 1281 | { |
---|
| 1282 | WRITE_UVLC( hrd->getPicDurationInTcMinus1( i ), "elemental_duration_in_tc_minus1"); |
---|
| 1283 | } |
---|
| 1284 | else |
---|
| 1285 | { |
---|
| 1286 | WRITE_FLAG( hrd->getLowDelayHrdFlag( i ) ? 1 : 0, "low_delay_hrd_flag"); |
---|
| 1287 | } |
---|
| 1288 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
| 1289 | { |
---|
| 1290 | WRITE_UVLC( hrd->getCpbCntMinus1( i ), "cpb_cnt_minus1"); |
---|
| 1291 | } |
---|
| 1292 | |
---|
| 1293 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
| 1294 | { |
---|
| 1295 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
| 1296 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
| 1297 | { |
---|
| 1298 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
| 1299 | { |
---|
| 1300 | WRITE_UVLC( hrd->getBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_value_minus1"); |
---|
| 1301 | WRITE_UVLC( hrd->getCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_value_minus1"); |
---|
| 1302 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 1303 | { |
---|
| 1304 | WRITE_UVLC( hrd->getDuCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_du_value_minus1"); |
---|
| 1305 | WRITE_UVLC( hrd->getDuBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_du_value_minus1"); |
---|
| 1306 | } |
---|
| 1307 | WRITE_FLAG( hrd->getCbrFlag( i, j, nalOrVcl ) ? 1 : 0, "cbr_flag"); |
---|
| 1308 | } |
---|
| 1309 | } |
---|
| 1310 | } |
---|
| 1311 | } |
---|
| 1312 | } |
---|
| 1313 | |
---|
| 1314 | #endif |
---|
| 1315 | |
---|
[1037] | 1316 | #if P0123_ALPHA_CHANNEL_SEI |
---|
| 1317 | Void SEIWriter::xWriteSEIAlphaChannelInfo(const SEIAlphaChannelInfo &sei) |
---|
| 1318 | { |
---|
| 1319 | WRITE_FLAG(sei.m_alphaChannelCancelFlag, "alpha_channel_cancel_flag"); |
---|
| 1320 | if(!sei.m_alphaChannelCancelFlag) |
---|
| 1321 | { |
---|
| 1322 | WRITE_CODE(sei.m_alphaChannelUseIdc, 3, "alpha_channel_use_idc"); |
---|
| 1323 | WRITE_CODE(sei.m_alphaChannelBitDepthMinus8, 3, "alpha_channel_bit_depth_minus8"); |
---|
| 1324 | WRITE_CODE(sei.m_alphaTransparentValue, sei.m_alphaChannelBitDepthMinus8 + 9, "alpha_transparent_value"); |
---|
| 1325 | WRITE_CODE(sei.m_alphaOpaqueValue, sei.m_alphaChannelBitDepthMinus8 + 9, "alpha_opaque_value"); |
---|
| 1326 | WRITE_FLAG(sei.m_alphaChannelIncrFlag, "alpha_channel_incr_flag"); |
---|
| 1327 | WRITE_FLAG(sei.m_alphaChannelClipFlag, "alpha_channel_clip_flag"); |
---|
| 1328 | if(sei.m_alphaChannelClipFlag) |
---|
| 1329 | { |
---|
| 1330 | WRITE_FLAG(sei.m_alphaChannelClipTypeFlag, "alpha_channel_clip_type_flag"); |
---|
| 1331 | } |
---|
| 1332 | } |
---|
| 1333 | xWriteByteAlign(); |
---|
| 1334 | } |
---|
| 1335 | #endif |
---|
| 1336 | |
---|
[912] | 1337 | #if Q0096_OVERLAY_SEI |
---|
| 1338 | Void SEIWriter::xWriteSEIOverlayInfo(const SEIOverlayInfo &sei) |
---|
| 1339 | { |
---|
| 1340 | Int i,j; |
---|
| 1341 | WRITE_FLAG( sei.m_overlayInfoCancelFlag, "overlay_info_cancel_flag" ); |
---|
| 1342 | if ( !sei.m_overlayInfoCancelFlag ) |
---|
| 1343 | { |
---|
| 1344 | WRITE_UVLC( sei.m_overlayContentAuxIdMinus128, "overlay_content_aux_id_minus128" ); |
---|
| 1345 | WRITE_UVLC( sei.m_overlayLabelAuxIdMinus128, "overlay_label_aux_id_minus128" ); |
---|
| 1346 | WRITE_UVLC( sei.m_overlayAlphaAuxIdMinus128, "overlay_alpha_aux_id_minus128" ); |
---|
| 1347 | WRITE_UVLC( sei.m_overlayElementLabelValueLengthMinus8, "overlay_element_label_value_length_minus8" ); |
---|
| 1348 | assert( sei.m_numOverlaysMinus1 < MAX_OVERLAYS ); |
---|
| 1349 | WRITE_UVLC( sei.m_numOverlaysMinus1, "num_overlays_minus1" ); |
---|
| 1350 | for (i=0 ; i<=sei.m_numOverlaysMinus1 ; i++) |
---|
| 1351 | { |
---|
| 1352 | WRITE_UVLC( sei.m_overlayIdx[i], "overlay_idx" ); |
---|
| 1353 | WRITE_FLAG( sei.m_languageOverlayPresentFlag[i], "language_overlay_present_flag" ); |
---|
| 1354 | WRITE_CODE( sei.m_overlayContentLayerId[i], 6, "overlay_content_layer_id"); |
---|
| 1355 | WRITE_FLAG( sei.m_overlayLabelPresentFlag[i], "overlay_label_present_flag" ); |
---|
| 1356 | if ( sei.m_overlayLabelPresentFlag[i] ) |
---|
| 1357 | { |
---|
| 1358 | WRITE_CODE( sei.m_overlayLabelLayerId[i], 6, "overlay_label_layer_id"); |
---|
| 1359 | } |
---|
| 1360 | WRITE_FLAG( sei.m_overlayAlphaPresentFlag[i], "overlay_alpha_present_flag" ); |
---|
| 1361 | if ( sei.m_overlayAlphaPresentFlag[i] ) |
---|
| 1362 | { |
---|
| 1363 | WRITE_CODE( sei.m_overlayAlphaLayerId[i], 6, "overlay_alpha_layer_id"); |
---|
| 1364 | } |
---|
| 1365 | if ( sei.m_overlayLabelPresentFlag[i] ) |
---|
| 1366 | { |
---|
| 1367 | assert( sei.m_numOverlayElementsMinus1[i] < MAX_OVERLAY_ELEMENTS ); |
---|
| 1368 | WRITE_UVLC( sei.m_numOverlayElementsMinus1[i], "num_overlay_elements_minus1"); |
---|
| 1369 | for ( j=0 ; j<=sei.m_numOverlayElementsMinus1[i] ; j++ ) |
---|
| 1370 | { |
---|
| 1371 | WRITE_CODE(sei.m_overlayElementLabelMin[i][j], sei.m_overlayElementLabelValueLengthMinus8 + 8, "overlay_element_label_min"); |
---|
| 1372 | WRITE_CODE(sei.m_overlayElementLabelMax[i][j], sei.m_overlayElementLabelValueLengthMinus8 + 8, "overlay_element_label_max"); |
---|
| 1373 | } |
---|
| 1374 | } |
---|
| 1375 | } |
---|
| 1376 | |
---|
| 1377 | |
---|
| 1378 | // byte alignment |
---|
| 1379 | while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) |
---|
| 1380 | { |
---|
| 1381 | WRITE_FLAG( 0, "overlay_zero_bit" ); |
---|
| 1382 | } |
---|
| 1383 | |
---|
| 1384 | for ( i=0 ; i<=sei.m_numOverlaysMinus1 ; i++ ) |
---|
| 1385 | { |
---|
| 1386 | if ( sei.m_languageOverlayPresentFlag[i] ) |
---|
| 1387 | { |
---|
| 1388 | WRITE_STRING( sei.m_overlayLanguage[i], sei.m_overlayLanguageLength[i], "overlay_language" ); //WRITE_STRING adds zero-termination byte |
---|
| 1389 | } |
---|
| 1390 | WRITE_STRING( sei.m_overlayName[i], sei.m_overlayNameLength[i], "overlay_name" ); |
---|
| 1391 | if ( sei.m_overlayLabelPresentFlag[i] ) |
---|
| 1392 | { |
---|
| 1393 | for ( j=0 ; j<=sei.m_numOverlayElementsMinus1[i] ; j++) |
---|
| 1394 | { |
---|
| 1395 | WRITE_STRING( sei.m_overlayElementName[i][j], sei.m_overlayElementNameLength[i][j], "overlay_element_name" ); |
---|
| 1396 | } |
---|
| 1397 | } |
---|
| 1398 | } |
---|
| 1399 | WRITE_FLAG( sei.m_overlayInfoPersistenceFlag, "overlay_info_persistence_flag" ); |
---|
| 1400 | } |
---|
| 1401 | } |
---|
| 1402 | #endif |
---|
| 1403 | |
---|
[595] | 1404 | #endif //SVC_EXTENSION |
---|
[313] | 1405 | |
---|
| 1406 | //! \} |
---|