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