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