[5] | 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 |
---|
[1200] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[1200] | 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
[5] | 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. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 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 | */ |
---|
[2] | 33 | |
---|
| 34 | /** \file TEncCavlc.cpp |
---|
| 35 | \brief CAVLC encoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
[56] | 38 | #include "../TLibCommon/CommonDef.h" |
---|
[2] | 39 | #include "TEncCavlc.h" |
---|
| 40 | #include "SEIwrite.h" |
---|
[1200] | 41 | |
---|
| 42 | #if NH_3D |
---|
[1179] | 43 | #include "TEncTop.h" |
---|
| 44 | #endif |
---|
[1200] | 45 | |
---|
[56] | 46 | //! \ingroup TLibEncoder |
---|
| 47 | //! \{ |
---|
[2] | 48 | |
---|
[56] | 49 | #if ENC_DEC_TRACE |
---|
| 50 | |
---|
[1200] | 51 | #if !H_MV_ENC_DEC_TRAC |
---|
| 52 | Void xTraceVPSHeader () |
---|
[2] | 53 | { |
---|
[1200] | 54 | fprintf( g_hTrace, "=========== Video Parameter Set ===========\n" ); |
---|
| 55 | |
---|
| 56 | Void xTraceSPSHeader () |
---|
| 57 | { |
---|
| 58 | fprintf( g_hTrace, "=========== Sequence Parameter Set ===========\n" ); |
---|
[56] | 59 | } |
---|
[2] | 60 | |
---|
[1200] | 61 | Void xTracePPSHeader () |
---|
[56] | 62 | { |
---|
[1200] | 63 | fprintf( g_hTrace, "=========== Picture Parameter Set ===========\n"); |
---|
[2] | 64 | } |
---|
| 65 | |
---|
[1200] | 66 | Void xTraceSliceHeader ( ) |
---|
[56] | 67 | { |
---|
| 68 | fprintf( g_hTrace, "=========== Slice ===========\n"); |
---|
| 69 | } |
---|
[2] | 70 | #endif |
---|
[1200] | 71 | #endif |
---|
[56] | 72 | // ==================================================================================================================== |
---|
| 73 | // Constructor / destructor / create / destroy |
---|
| 74 | // ==================================================================================================================== |
---|
[2] | 75 | |
---|
[56] | 76 | TEncCavlc::TEncCavlc() |
---|
[2] | 77 | { |
---|
[56] | 78 | m_pcBitIf = NULL; |
---|
[2] | 79 | } |
---|
| 80 | |
---|
[56] | 81 | TEncCavlc::~TEncCavlc() |
---|
[2] | 82 | { |
---|
| 83 | } |
---|
| 84 | |
---|
[56] | 85 | |
---|
| 86 | // ==================================================================================================================== |
---|
| 87 | // Public member functions |
---|
| 88 | // ==================================================================================================================== |
---|
| 89 | |
---|
[1200] | 90 | Void TEncCavlc::resetEntropy(const TComSlice* /*pSlice*/) |
---|
[2] | 91 | { |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | |
---|
[1200] | 95 | Void TEncCavlc::codeShortTermRefPicSet( const TComReferencePictureSet* rps, Bool calledFromSliceHeader, Int idx) |
---|
[42] | 96 | { |
---|
[56] | 97 | #if PRINT_RPS_INFO |
---|
[608] | 98 | Int lastBits = getNumberOfWrittenBits(); |
---|
[2] | 99 | #endif |
---|
[608] | 100 | if (idx > 0) |
---|
| 101 | { |
---|
[56] | 102 | WRITE_FLAG( rps->getInterRPSPrediction(), "inter_ref_pic_set_prediction_flag" ); // inter_RPS_prediction_flag |
---|
[608] | 103 | } |
---|
| 104 | if (rps->getInterRPSPrediction()) |
---|
[56] | 105 | { |
---|
| 106 | Int deltaRPS = rps->getDeltaRPS(); |
---|
[608] | 107 | if(calledFromSliceHeader) |
---|
| 108 | { |
---|
| 109 | WRITE_UVLC( rps->getDeltaRIdxMinus1(), "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1 |
---|
| 110 | } |
---|
| 111 | |
---|
[56] | 112 | WRITE_CODE( (deltaRPS >=0 ? 0: 1), 1, "delta_rps_sign" ); //delta_rps_sign |
---|
| 113 | WRITE_UVLC( abs(deltaRPS) - 1, "abs_delta_rps_minus1"); // absolute delta RPS minus 1 |
---|
[2] | 114 | |
---|
[56] | 115 | for(Int j=0; j < rps->getNumRefIdc(); j++) |
---|
| 116 | { |
---|
| 117 | Int refIdc = rps->getRefIdc(j); |
---|
[1200] | 118 | WRITE_CODE( (refIdc==1? 1: 0), 1, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 |
---|
| 119 | if (refIdc != 1) |
---|
[56] | 120 | { |
---|
| 121 | WRITE_CODE( refIdc>>1, 1, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise. |
---|
| 122 | } |
---|
| 123 | } |
---|
[2] | 124 | } |
---|
[56] | 125 | else |
---|
[2] | 126 | { |
---|
[56] | 127 | WRITE_UVLC( rps->getNumberOfNegativePictures(), "num_negative_pics" ); |
---|
| 128 | WRITE_UVLC( rps->getNumberOfPositivePictures(), "num_positive_pics" ); |
---|
| 129 | Int prev = 0; |
---|
| 130 | for(Int j=0 ; j < rps->getNumberOfNegativePictures(); j++) |
---|
[2] | 131 | { |
---|
[56] | 132 | WRITE_UVLC( prev-rps->getDeltaPOC(j)-1, "delta_poc_s0_minus1" ); |
---|
| 133 | prev = rps->getDeltaPOC(j); |
---|
[1200] | 134 | WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s0_flag"); |
---|
[2] | 135 | } |
---|
[56] | 136 | prev = 0; |
---|
| 137 | for(Int j=rps->getNumberOfNegativePictures(); j < rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); j++) |
---|
[2] | 138 | { |
---|
[56] | 139 | WRITE_UVLC( rps->getDeltaPOC(j)-prev-1, "delta_poc_s1_minus1" ); |
---|
| 140 | prev = rps->getDeltaPOC(j); |
---|
[1200] | 141 | WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s1_flag" ); |
---|
[2] | 142 | } |
---|
| 143 | } |
---|
[56] | 144 | |
---|
| 145 | #if PRINT_RPS_INFO |
---|
| 146 | printf("irps=%d (%2d bits) ", rps->getInterRPSPrediction(), getNumberOfWrittenBits() - lastBits); |
---|
| 147 | rps->printDeltaPOC(); |
---|
| 148 | #endif |
---|
[2] | 149 | } |
---|
| 150 | |
---|
[56] | 151 | |
---|
[1200] | 152 | Void TEncCavlc::codePPS( const TComPPS* pcPPS ) |
---|
[2] | 153 | { |
---|
[1200] | 154 | #if ENC_DEC_TRACE |
---|
| 155 | #if H_MV_ENC_DEC_TRAC |
---|
| 156 | tracePSHeader( "PPS", pcPPS->getLayerId() ); |
---|
| 157 | #else |
---|
| 158 | xTracePPSHeader (); |
---|
[42] | 159 | #endif |
---|
[1200] | 160 | #endif |
---|
[608] | 161 | WRITE_UVLC( pcPPS->getPPSId(), "pps_pic_parameter_set_id" ); |
---|
| 162 | WRITE_UVLC( pcPPS->getSPSId(), "pps_seq_parameter_set_id" ); |
---|
| 163 | WRITE_FLAG( pcPPS->getDependentSliceSegmentsEnabledFlag() ? 1 : 0, "dependent_slice_segments_enabled_flag" ); |
---|
| 164 | WRITE_FLAG( pcPPS->getOutputFlagPresentFlag() ? 1 : 0, "output_flag_present_flag" ); |
---|
| 165 | WRITE_CODE( pcPPS->getNumExtraSliceHeaderBits(), 3, "num_extra_slice_header_bits"); |
---|
[56] | 166 | WRITE_FLAG( pcPPS->getSignHideFlag(), "sign_data_hiding_flag" ); |
---|
| 167 | WRITE_FLAG( pcPPS->getCabacInitPresentFlag() ? 1 : 0, "cabac_init_present_flag" ); |
---|
[773] | 168 | #if PPS_FIX_DEPTH |
---|
| 169 | if( pcPPS->getSPS()->getVPS()->getDepthId(pcPPS->getSPS()->getLayerId()) ) |
---|
| 170 | { |
---|
| 171 | WRITE_UVLC( pcPPS->getNumRefIdxL0DefaultActive(), "num_ref_idx_l0_default_active_minus1"); |
---|
| 172 | WRITE_UVLC( pcPPS->getNumRefIdxL1DefaultActive(), "num_ref_idx_l1_default_active_minus1"); |
---|
| 173 | } |
---|
| 174 | else |
---|
| 175 | { |
---|
| 176 | #endif |
---|
[608] | 177 | WRITE_UVLC( pcPPS->getNumRefIdxL0DefaultActive()-1, "num_ref_idx_l0_default_active_minus1"); |
---|
| 178 | WRITE_UVLC( pcPPS->getNumRefIdxL1DefaultActive()-1, "num_ref_idx_l1_default_active_minus1"); |
---|
[773] | 179 | #if PPS_FIX_DEPTH |
---|
| 180 | } |
---|
| 181 | #endif |
---|
[608] | 182 | WRITE_SVLC( pcPPS->getPicInitQPMinus26(), "init_qp_minus26"); |
---|
| 183 | WRITE_FLAG( pcPPS->getConstrainedIntraPred() ? 1 : 0, "constrained_intra_pred_flag" ); |
---|
[1200] | 184 | WRITE_FLAG( pcPPS->getUseTransformSkip() ? 1 : 0, "transform_skip_enabled_flag" ); |
---|
[608] | 185 | WRITE_FLAG( pcPPS->getUseDQP() ? 1 : 0, "cu_qp_delta_enabled_flag" ); |
---|
| 186 | if ( pcPPS->getUseDQP() ) |
---|
[2] | 187 | { |
---|
[608] | 188 | WRITE_UVLC( pcPPS->getMaxCuDQPDepth(), "diff_cu_qp_delta_depth" ); |
---|
[2] | 189 | } |
---|
[1200] | 190 | |
---|
| 191 | WRITE_SVLC( pcPPS->getQpOffset(COMPONENT_Cb), "pps_cb_qp_offset" ); |
---|
| 192 | WRITE_SVLC( pcPPS->getQpOffset(COMPONENT_Cr), "pps_cr_qp_offset" ); |
---|
| 193 | |
---|
[608] | 194 | WRITE_FLAG( pcPPS->getSliceChromaQpFlag() ? 1 : 0, "pps_slice_chroma_qp_offsets_present_flag" ); |
---|
[2] | 195 | |
---|
[56] | 196 | WRITE_FLAG( pcPPS->getUseWP() ? 1 : 0, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) |
---|
[608] | 197 | WRITE_FLAG( pcPPS->getWPBiPred() ? 1 : 0, "weighted_bipred_flag" ); // Use of Weighting Bi-Prediction (B_SLICE) |
---|
| 198 | WRITE_FLAG( pcPPS->getTransquantBypassEnableFlag() ? 1 : 0, "transquant_bypass_enable_flag" ); |
---|
| 199 | WRITE_FLAG( pcPPS->getTilesEnabledFlag() ? 1 : 0, "tiles_enabled_flag" ); |
---|
| 200 | WRITE_FLAG( pcPPS->getEntropyCodingSyncEnabledFlag() ? 1 : 0, "entropy_coding_sync_enabled_flag" ); |
---|
| 201 | if( pcPPS->getTilesEnabledFlag() ) |
---|
[56] | 202 | { |
---|
[1084] | 203 | WRITE_UVLC( pcPPS->getNumTileColumnsMinus1(), "num_tile_columns_minus1" ); |
---|
[1200] | 204 | WRITE_UVLC( pcPPS->getNumTileRowsMinus1(), "num_tile_rows_minus1" ); |
---|
[1084] | 205 | WRITE_FLAG( pcPPS->getTileUniformSpacingFlag(), "uniform_spacing_flag" ); |
---|
| 206 | if( !pcPPS->getTileUniformSpacingFlag() ) |
---|
[2] | 207 | { |
---|
[1084] | 208 | for(UInt i=0; i<pcPPS->getNumTileColumnsMinus1(); i++) |
---|
[2] | 209 | { |
---|
[1084] | 210 | WRITE_UVLC( pcPPS->getTileColumnWidth(i)-1, "column_width_minus1" ); |
---|
[2] | 211 | } |
---|
[1200] | 212 | for(UInt i=0; i<pcPPS->getNumTileRowsMinus1(); i++) |
---|
[2] | 213 | { |
---|
[1084] | 214 | WRITE_UVLC( pcPPS->getTileRowHeight(i)-1, "row_height_minus1" ); |
---|
[2] | 215 | } |
---|
| 216 | } |
---|
[1200] | 217 | if(pcPPS->getNumTileColumnsMinus1() !=0 || pcPPS->getNumTileRowsMinus1() !=0) |
---|
[608] | 218 | { |
---|
| 219 | WRITE_FLAG( pcPPS->getLoopFilterAcrossTilesEnabledFlag()?1 : 0, "loop_filter_across_tiles_enabled_flag"); |
---|
| 220 | } |
---|
[2] | 221 | } |
---|
[1200] | 222 | WRITE_FLAG( pcPPS->getLoopFilterAcrossSlicesEnabledFlag()?1 : 0, "pps_loop_filter_across_slices_enabled_flag"); |
---|
[608] | 223 | WRITE_FLAG( pcPPS->getDeblockingFilterControlPresentFlag()?1 : 0, "deblocking_filter_control_present_flag"); |
---|
| 224 | if(pcPPS->getDeblockingFilterControlPresentFlag()) |
---|
[2] | 225 | { |
---|
[1200] | 226 | WRITE_FLAG( pcPPS->getDeblockingFilterOverrideEnabledFlag() ? 1 : 0, "deblocking_filter_override_enabled_flag" ); |
---|
[608] | 227 | WRITE_FLAG( pcPPS->getPicDisableDeblockingFilterFlag() ? 1 : 0, "pps_disable_deblocking_filter_flag" ); |
---|
| 228 | if(!pcPPS->getPicDisableDeblockingFilterFlag()) |
---|
| 229 | { |
---|
| 230 | WRITE_SVLC( pcPPS->getDeblockingFilterBetaOffsetDiv2(), "pps_beta_offset_div2" ); |
---|
| 231 | WRITE_SVLC( pcPPS->getDeblockingFilterTcOffsetDiv2(), "pps_tc_offset_div2" ); |
---|
| 232 | } |
---|
[2] | 233 | } |
---|
[1200] | 234 | WRITE_FLAG( pcPPS->getScalingListPresentFlag() ? 1 : 0, "pps_scaling_list_data_present_flag" ); |
---|
[608] | 235 | if( pcPPS->getScalingListPresentFlag() ) |
---|
| 236 | { |
---|
[1200] | 237 | codeScalingList( pcPPS->getScalingList() ); |
---|
[608] | 238 | } |
---|
[773] | 239 | #if PPS_FIX_DEPTH |
---|
| 240 | if( pcPPS->getSPS()->getVPS()->getDepthId(pcPPS->getSPS()->getLayerId()) ) |
---|
| 241 | { |
---|
| 242 | WRITE_FLAG( 1, "lists_modification_present_flag" ); |
---|
| 243 | } |
---|
| 244 | else |
---|
| 245 | #endif |
---|
[608] | 246 | WRITE_FLAG( pcPPS->getListsModificationPresentFlag(), "lists_modification_present_flag"); |
---|
[56] | 247 | WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2"); |
---|
[872] | 248 | WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_segment_header_extension_present_flag"); |
---|
[1200] | 249 | #if !NH_MV |
---|
| 250 | Bool pps_extension_present_flag=false; |
---|
| 251 | Bool pps_extension_flags[NUM_PPS_EXTENSION_FLAGS]={false}; |
---|
[872] | 252 | |
---|
[1200] | 253 | pps_extension_flags[PPS_EXT__REXT] = pcPPS->getPpsRangeExtension().settingsDifferFromDefaults(pcPPS->getUseTransformSkip()); |
---|
| 254 | |
---|
| 255 | // Other PPS extension flags checked here. |
---|
| 256 | |
---|
| 257 | for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) |
---|
| 258 | { |
---|
| 259 | pps_extension_present_flag|=pps_extension_flags[i]; |
---|
| 260 | } |
---|
| 261 | |
---|
| 262 | WRITE_FLAG( (pps_extension_present_flag?1:0), "pps_extension_present_flag" ); |
---|
| 263 | |
---|
| 264 | if (pps_extension_present_flag) |
---|
| 265 | { |
---|
| 266 | #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
| 267 | static const char *syntaxStrings[]={ "pps_range_extension_flag", |
---|
| 268 | "pps_multilayer_extension_flag", |
---|
| 269 | "pps_extension_6bits[0]", |
---|
| 270 | "pps_extension_6bits[1]", |
---|
| 271 | "pps_extension_6bits[2]", |
---|
| 272 | "pps_extension_6bits[3]", |
---|
| 273 | "pps_extension_6bits[4]", |
---|
| 274 | "pps_extension_6bits[5]" }; |
---|
| 275 | #endif |
---|
| 276 | |
---|
| 277 | for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) |
---|
[950] | 278 | { |
---|
[1200] | 279 | WRITE_FLAG( pps_extension_flags[i]?1:0, syntaxStrings[i] ); |
---|
[950] | 280 | } |
---|
| 281 | |
---|
[1200] | 282 | for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. |
---|
| 283 | { |
---|
| 284 | if (pps_extension_flags[i]) |
---|
| 285 | { |
---|
| 286 | switch (PPSExtensionFlagIndex(i)) |
---|
| 287 | { |
---|
| 288 | case PPS_EXT__REXT: |
---|
| 289 | { |
---|
| 290 | const TComPPSRExt &ppsRangeExtension = pcPPS->getPpsRangeExtension(); |
---|
| 291 | if (pcPPS->getUseTransformSkip()) |
---|
| 292 | { |
---|
| 293 | WRITE_UVLC( ppsRangeExtension.getLog2MaxTransformSkipBlockSize()-2, "log2_max_transform_skip_block_size_minus2"); |
---|
| 294 | } |
---|
| 295 | |
---|
| 296 | WRITE_FLAG((ppsRangeExtension.getCrossComponentPredictionEnabledFlag() ? 1 : 0), "cross_component_prediction_enabled_flag" ); |
---|
| 297 | |
---|
| 298 | WRITE_FLAG(UInt(ppsRangeExtension.getChromaQpOffsetListEnabledFlag()), "chroma_qp_offset_list_enabled_flag" ); |
---|
| 299 | if (ppsRangeExtension.getChromaQpOffsetListEnabledFlag()) |
---|
| 300 | { |
---|
| 301 | WRITE_UVLC(ppsRangeExtension.getDiffCuChromaQpOffsetDepth(), "diff_cu_chroma_qp_offset_depth"); |
---|
| 302 | WRITE_UVLC(ppsRangeExtension.getChromaQpOffsetListLen() - 1, "chroma_qp_offset_list_len_minus1"); |
---|
| 303 | /* skip zero index */ |
---|
| 304 | for (Int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx < ppsRangeExtension.getChromaQpOffsetListLen(); cuChromaQpOffsetIdx++) |
---|
| 305 | { |
---|
| 306 | WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CbOffset, "cb_qp_offset_list[i]"); |
---|
| 307 | WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CrOffset, "cr_qp_offset_list[i]"); |
---|
| 308 | } |
---|
| 309 | } |
---|
| 310 | |
---|
| 311 | WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA), "log2_sao_offset_scale_luma" ); |
---|
| 312 | WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA), "log2_sao_offset_scale_chroma" ); |
---|
| 313 | } |
---|
| 314 | break; |
---|
| 315 | default: |
---|
| 316 | assert(pps_extension_flags[i]==false); // Should never get here with an active PPS extension flag. |
---|
| 317 | break; |
---|
| 318 | } // switch |
---|
| 319 | } // if flag present |
---|
| 320 | } // loop over PPS flags |
---|
| 321 | } // pps_extension_present_flag is non-zero |
---|
[872] | 322 | #else |
---|
[1200] | 323 | WRITE_FLAG( 1, "pps_extension_present_flag" ); |
---|
[872] | 324 | |
---|
[964] | 325 | WRITE_FLAG( pcPPS->getPpsRangeExtensionsFlag( ) ? 1 : 0 , "pps_range_extensions_flag" ); |
---|
| 326 | WRITE_FLAG( pcPPS->getPpsMultilayerExtensionFlag( ) ? 1 : 0 , "pps_multilayer_extension_flag" ); |
---|
| 327 | WRITE_FLAG( pcPPS->getPps3dExtensionFlag( ) ? 1 : 0 , "pps_3d_extension_flag" ); |
---|
| 328 | WRITE_CODE( pcPPS->getPpsExtension5bits( ), 5, "pps_extension_5bits" ); |
---|
| 329 | if ( pcPPS->getPpsRangeExtensionsFlag() ) |
---|
| 330 | { |
---|
[1200] | 331 | const TComPPSRExt &ppsRangeExtension = pcPPS->getPpsRangeExtension(); |
---|
| 332 | if (pcPPS->getUseTransformSkip()) |
---|
| 333 | { |
---|
| 334 | WRITE_UVLC( ppsRangeExtension.getLog2MaxTransformSkipBlockSize()-2, "log2_max_transform_skip_block_size_minus2"); |
---|
| 335 | } |
---|
| 336 | |
---|
| 337 | WRITE_FLAG((ppsRangeExtension.getCrossComponentPredictionEnabledFlag() ? 1 : 0), "cross_component_prediction_enabled_flag" ); |
---|
| 338 | |
---|
| 339 | WRITE_FLAG(UInt(ppsRangeExtension.getChromaQpOffsetListEnabledFlag()), "chroma_qp_offset_list_enabled_flag" ); |
---|
| 340 | if (ppsRangeExtension.getChromaQpOffsetListEnabledFlag()) |
---|
| 341 | { |
---|
| 342 | WRITE_UVLC(ppsRangeExtension.getDiffCuChromaQpOffsetDepth(), "diff_cu_chroma_qp_offset_depth"); |
---|
| 343 | WRITE_UVLC(ppsRangeExtension.getChromaQpOffsetListLen() - 1, "chroma_qp_offset_list_len_minus1"); |
---|
| 344 | /* skip zero index */ |
---|
| 345 | for (Int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx < ppsRangeExtension.getChromaQpOffsetListLen(); cuChromaQpOffsetIdx++) |
---|
| 346 | { |
---|
| 347 | WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CbOffset, "cb_qp_offset_list[i]"); |
---|
| 348 | WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CrOffset, "cr_qp_offset_list[i]"); |
---|
| 349 | } |
---|
| 350 | } |
---|
| 351 | |
---|
| 352 | WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA), "log2_sao_offset_scale_luma" ); |
---|
| 353 | WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA), "log2_sao_offset_scale_chroma" ); |
---|
[964] | 354 | } |
---|
| 355 | |
---|
| 356 | if ( pcPPS->getPpsMultilayerExtensionFlag() ) |
---|
| 357 | { |
---|
[1200] | 358 | codePpsMultilayerExtension( pcPPS ); |
---|
[964] | 359 | } |
---|
| 360 | |
---|
[1200] | 361 | #if NH_3D |
---|
[964] | 362 | if( pcPPS->getPps3dExtensionFlag( ) ) // This probably needs to be aligned with Rext and SHVC |
---|
| 363 | { |
---|
[1200] | 364 | codePps3dExtension( pcPPS ); |
---|
[964] | 365 | } |
---|
| 366 | #endif |
---|
[872] | 367 | #endif |
---|
[1200] | 368 | xWriteRbspTrailingBits(); |
---|
[2] | 369 | } |
---|
| 370 | |
---|
[1200] | 371 | #if NH_3D |
---|
| 372 | Void TEncCavlc::codePps3dExtension ( const TComPPS* pcPPS ) |
---|
[758] | 373 | { |
---|
| 374 | // Assuming that all PPS indirectly refer to the same VPS via different SPS |
---|
| 375 | // There is no parsing dependency in decoding DLT in PPS. |
---|
| 376 | // The VPS information passed to decodePPS() is used to arrange the decoded DLT tables to their corresponding layers. |
---|
| 377 | // This is equivalent to the process of |
---|
| 378 | // Step 1) decoding DLT tables based on the number of depth layers, and |
---|
| 379 | // Step 2) mapping DLT tables to the depth layers |
---|
[773] | 380 | // as described in the 3D-HEVC WD. |
---|
[758] | 381 | |
---|
[1200] | 382 | // GT: Please remove dependency from VPS in the encoding as well as in the parsing function, e.g. using the equivalent process. |
---|
| 383 | // GT: Moreover this function should only carry out the coding of the DLT and NO rate based decisions. |
---|
| 384 | // GT: Please add a function e.g. xSetDLT in e.g. TEncSlice to find the best DLT syntax representation and do ONLY the coding of the DLT here !! |
---|
[758] | 385 | |
---|
[1200] | 386 | #if H_3D |
---|
[758] | 387 | WRITE_FLAG( pcDLT->getDltPresentFlag() ? 1 : 0, "dlt_present_flag" ); |
---|
| 388 | |
---|
| 389 | if ( pcDLT->getDltPresentFlag() ) |
---|
| 390 | { |
---|
| 391 | WRITE_CODE(pcDLT->getNumDepthViews(), 6, "pps_depth_layers_minus1"); |
---|
| 392 | WRITE_CODE((pcDLT->getDepthViewBitDepth() - 8), 4, "pps_bit_depth_for_depth_views_minus8"); |
---|
| 393 | |
---|
| 394 | for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 395 | { |
---|
| 396 | if ( i != 0 ) |
---|
| 397 | { |
---|
| 398 | if ( pcVPS->getDepthId( i ) == 1 ) |
---|
| 399 | { |
---|
| 400 | WRITE_FLAG( pcDLT->getUseDLTFlag( i ) ? 1 : 0, "dlt_flag[i]" ); |
---|
| 401 | |
---|
| 402 | if ( pcDLT->getUseDLTFlag( i ) ) |
---|
| 403 | { |
---|
| 404 | WRITE_FLAG( pcDLT->getInterViewDltPredEnableFlag( i ) ? 1 : 0, "inter_view_dlt_pred_enable_flag[ i ]"); |
---|
| 405 | |
---|
| 406 | // ----------------------------- determine whether to use bit-map ----------------------------- |
---|
| 407 | Bool bDltBitMapRepFlag = false; |
---|
| 408 | UInt uiNumBitsNonBitMap = 0; |
---|
| 409 | UInt uiNumBitsBitMap = 0; |
---|
| 410 | |
---|
| 411 | UInt uiMaxDiff = 0; |
---|
| 412 | UInt uiMinDiff = 0xffffffff; |
---|
| 413 | UInt uiLengthMinDiff = 0; |
---|
| 414 | UInt uiLengthDltDiffMinusMin = 0; |
---|
| 415 | |
---|
| 416 | UInt* puiDltDiffValues = NULL; |
---|
| 417 | |
---|
| 418 | Int aiIdx2DepthValue_coded[256]; |
---|
| 419 | UInt uiNumDepthValues_coded = 0; |
---|
| 420 | |
---|
| 421 | uiNumDepthValues_coded = pcDLT->getNumDepthValues(i); |
---|
| 422 | for( UInt ui = 0; ui<uiNumDepthValues_coded; ui++ ) |
---|
| 423 | { |
---|
| 424 | aiIdx2DepthValue_coded[ui] = pcDLT->idx2DepthValue(i, ui); |
---|
| 425 | } |
---|
| 426 | |
---|
| 427 | if( pcDLT->getInterViewDltPredEnableFlag( i ) ) |
---|
| 428 | { |
---|
| 429 | AOF( pcVPS->getDepthId( 1 ) == 1 ); |
---|
| 430 | AOF( i > 1 ); |
---|
| 431 | // assumes ref layer id to be 1 |
---|
| 432 | Int* piRefDLT = pcDLT->idx2DepthValue( 1 ); |
---|
| 433 | UInt uiRefNum = pcDLT->getNumDepthValues( 1 ); |
---|
| 434 | pcDLT->getDeltaDLT(i, piRefDLT, uiRefNum, aiIdx2DepthValue_coded, &uiNumDepthValues_coded); |
---|
| 435 | } |
---|
| 436 | |
---|
| 437 | if ( NULL == (puiDltDiffValues = (UInt *)calloc(uiNumDepthValues_coded, sizeof(UInt))) ) |
---|
| 438 | { |
---|
[1084] | 439 | // This should be changed to an assertion. |
---|
[758] | 440 | exit(-1); |
---|
| 441 | } |
---|
| 442 | |
---|
| 443 | for (UInt d = 1; d < uiNumDepthValues_coded; d++) |
---|
| 444 | { |
---|
| 445 | puiDltDiffValues[d] = aiIdx2DepthValue_coded[d] - aiIdx2DepthValue_coded[d-1]; |
---|
| 446 | |
---|
| 447 | if ( uiMaxDiff < puiDltDiffValues[d] ) |
---|
| 448 | { |
---|
| 449 | uiMaxDiff = puiDltDiffValues[d]; |
---|
| 450 | } |
---|
| 451 | |
---|
| 452 | if ( uiMinDiff > puiDltDiffValues[d] ) |
---|
| 453 | { |
---|
| 454 | uiMinDiff = puiDltDiffValues[d]; |
---|
| 455 | } |
---|
| 456 | } |
---|
| 457 | |
---|
| 458 | // counting bits |
---|
| 459 | // diff coding branch |
---|
| 460 | uiNumBitsNonBitMap += 8; // u(v) bits for num_depth_values_in_dlt[layerId] (i.e. num_entry[ layerId ]) |
---|
| 461 | |
---|
| 462 | if ( uiNumDepthValues_coded > 1 ) |
---|
| 463 | { |
---|
| 464 | uiNumBitsNonBitMap += 8; // u(v) bits for max_diff[ layerId ] |
---|
| 465 | } |
---|
| 466 | |
---|
| 467 | if ( uiNumDepthValues_coded > 2 ) |
---|
| 468 | { |
---|
| 469 | uiLengthMinDiff = (UInt) ceil(Log2(uiMaxDiff + 1)); |
---|
| 470 | uiNumBitsNonBitMap += uiLengthMinDiff; // u(v) bits for min_diff[ layerId ] |
---|
| 471 | } |
---|
| 472 | |
---|
| 473 | uiNumBitsNonBitMap += 8; // u(v) bits for dlt_depth_value0[ layerId ] |
---|
| 474 | |
---|
| 475 | if (uiMaxDiff > uiMinDiff) |
---|
| 476 | { |
---|
| 477 | uiLengthDltDiffMinusMin = (UInt) ceil(Log2(uiMaxDiff - uiMinDiff + 1)); |
---|
| 478 | uiNumBitsNonBitMap += uiLengthDltDiffMinusMin * (uiNumDepthValues_coded - 1); // u(v) bits for dlt_depth_value_diff_minus_min[ layerId ][ j ] |
---|
| 479 | } |
---|
| 480 | |
---|
| 481 | // bit map branch |
---|
| 482 | uiNumBitsBitMap = 256; // uiNumBitsBitMap = 1 << pcDLT->getDepthViewBitDepth(); |
---|
| 483 | |
---|
| 484 | // determine bDltBitMapFlag |
---|
| 485 | bDltBitMapRepFlag = (uiNumBitsBitMap > uiNumBitsNonBitMap) ? false : true; |
---|
| 486 | |
---|
| 487 | // ----------------------------- Actual coding ----------------------------- |
---|
| 488 | if ( pcDLT->getInterViewDltPredEnableFlag( i ) == false ) |
---|
| 489 | { |
---|
| 490 | WRITE_FLAG( bDltBitMapRepFlag ? 1 : 0, "dlt_bit_map_rep_flag[ layerId ]" ); |
---|
| 491 | } |
---|
| 492 | else |
---|
| 493 | { |
---|
| 494 | bDltBitMapRepFlag = false; |
---|
| 495 | } |
---|
| 496 | |
---|
| 497 | // bit map coding |
---|
| 498 | if ( bDltBitMapRepFlag ) |
---|
| 499 | { |
---|
| 500 | UInt uiDltArrayIndex = 0; |
---|
| 501 | for (UInt d=0; d < 256; d++) |
---|
| 502 | { |
---|
| 503 | if ( d == aiIdx2DepthValue_coded[uiDltArrayIndex] ) |
---|
| 504 | { |
---|
| 505 | WRITE_FLAG(1, "dlt_bit_map_flag[ layerId ][ j ]"); |
---|
| 506 | uiDltArrayIndex++; |
---|
| 507 | } |
---|
| 508 | else |
---|
| 509 | { |
---|
| 510 | WRITE_FLAG(0, "dlt_bit_map_flag[ layerId ][ j ]"); |
---|
| 511 | } |
---|
| 512 | } |
---|
| 513 | } |
---|
| 514 | // Diff Coding |
---|
| 515 | else |
---|
| 516 | { |
---|
[872] | 517 | WRITE_CODE(uiNumDepthValues_coded, 8, "num_depth_values_in_dlt[i]"); // num_entry |
---|
[758] | 518 | { |
---|
| 519 | // The condition if( uiNumDepthValues_coded > 0 ) is always true since for Single-view Diff Coding, there is at least one depth value in depth component. |
---|
| 520 | if ( uiNumDepthValues_coded > 1 ) |
---|
| 521 | { |
---|
| 522 | WRITE_CODE(uiMaxDiff, 8, "max_diff[ layerId ]"); // max_diff |
---|
| 523 | } |
---|
| 524 | |
---|
| 525 | if ( uiNumDepthValues_coded > 2 ) |
---|
| 526 | { |
---|
| 527 | WRITE_CODE((uiMinDiff - 1), uiLengthMinDiff, "min_diff_minus1[ layerId ]"); // min_diff_minus1 |
---|
| 528 | } |
---|
| 529 | |
---|
| 530 | WRITE_CODE(aiIdx2DepthValue_coded[0], 8, "dlt_depth_value0[layerId]"); // entry0 |
---|
| 531 | |
---|
| 532 | if (uiMaxDiff > uiMinDiff) |
---|
| 533 | { |
---|
| 534 | for (UInt d=1; d < uiNumDepthValues_coded; d++) |
---|
| 535 | { |
---|
| 536 | WRITE_CODE( (puiDltDiffValues[d] - uiMinDiff), uiLengthDltDiffMinusMin, "dlt_depth_value_diff_minus_min[ layerId ][ j ]"); // entry_value_diff_minus_min[ k ] |
---|
| 537 | } |
---|
| 538 | } |
---|
| 539 | } |
---|
| 540 | } |
---|
| 541 | |
---|
| 542 | free(puiDltDiffValues); |
---|
| 543 | } |
---|
| 544 | } |
---|
| 545 | } |
---|
| 546 | } |
---|
| 547 | } |
---|
[1200] | 548 | #endif |
---|
[758] | 549 | } |
---|
| 550 | #endif |
---|
| 551 | |
---|
[1200] | 552 | Void TEncCavlc::codeVUI( const TComVUI *pcVUI, const TComSPS* pcSPS ) |
---|
[210] | 553 | { |
---|
[608] | 554 | #if ENC_DEC_TRACE |
---|
| 555 | fprintf( g_hTrace, "----------- vui_parameters -----------\n"); |
---|
| 556 | #endif |
---|
| 557 | WRITE_FLAG(pcVUI->getAspectRatioInfoPresentFlag(), "aspect_ratio_info_present_flag"); |
---|
| 558 | if (pcVUI->getAspectRatioInfoPresentFlag()) |
---|
[210] | 559 | { |
---|
[608] | 560 | WRITE_CODE(pcVUI->getAspectRatioIdc(), 8, "aspect_ratio_idc" ); |
---|
| 561 | if (pcVUI->getAspectRatioIdc() == 255) |
---|
| 562 | { |
---|
| 563 | WRITE_CODE(pcVUI->getSarWidth(), 16, "sar_width"); |
---|
| 564 | WRITE_CODE(pcVUI->getSarHeight(), 16, "sar_height"); |
---|
| 565 | } |
---|
[210] | 566 | } |
---|
[608] | 567 | WRITE_FLAG(pcVUI->getOverscanInfoPresentFlag(), "overscan_info_present_flag"); |
---|
| 568 | if (pcVUI->getOverscanInfoPresentFlag()) |
---|
[210] | 569 | { |
---|
[608] | 570 | WRITE_FLAG(pcVUI->getOverscanAppropriateFlag(), "overscan_appropriate_flag"); |
---|
[210] | 571 | } |
---|
[608] | 572 | WRITE_FLAG(pcVUI->getVideoSignalTypePresentFlag(), "video_signal_type_present_flag"); |
---|
[1200] | 573 | #if NH_MV |
---|
[738] | 574 | assert( pcSPS->getLayerId() == 0 || !pcVUI->getVideoSignalTypePresentFlag() ); |
---|
| 575 | #endif |
---|
[608] | 576 | if (pcVUI->getVideoSignalTypePresentFlag()) |
---|
| 577 | { |
---|
| 578 | WRITE_CODE(pcVUI->getVideoFormat(), 3, "video_format"); |
---|
| 579 | WRITE_FLAG(pcVUI->getVideoFullRangeFlag(), "video_full_range_flag"); |
---|
| 580 | WRITE_FLAG(pcVUI->getColourDescriptionPresentFlag(), "colour_description_present_flag"); |
---|
| 581 | if (pcVUI->getColourDescriptionPresentFlag()) |
---|
| 582 | { |
---|
| 583 | WRITE_CODE(pcVUI->getColourPrimaries(), 8, "colour_primaries"); |
---|
| 584 | WRITE_CODE(pcVUI->getTransferCharacteristics(), 8, "transfer_characteristics"); |
---|
[1200] | 585 | WRITE_CODE(pcVUI->getMatrixCoefficients(), 8, "matrix_coeffs"); |
---|
[608] | 586 | } |
---|
| 587 | } |
---|
[210] | 588 | |
---|
[608] | 589 | WRITE_FLAG(pcVUI->getChromaLocInfoPresentFlag(), "chroma_loc_info_present_flag"); |
---|
| 590 | if (pcVUI->getChromaLocInfoPresentFlag()) |
---|
[210] | 591 | { |
---|
[608] | 592 | WRITE_UVLC(pcVUI->getChromaSampleLocTypeTopField(), "chroma_sample_loc_type_top_field"); |
---|
| 593 | WRITE_UVLC(pcVUI->getChromaSampleLocTypeBottomField(), "chroma_sample_loc_type_bottom_field"); |
---|
| 594 | } |
---|
| 595 | |
---|
| 596 | WRITE_FLAG(pcVUI->getNeutralChromaIndicationFlag(), "neutral_chroma_indication_flag"); |
---|
| 597 | WRITE_FLAG(pcVUI->getFieldSeqFlag(), "field_seq_flag"); |
---|
| 598 | WRITE_FLAG(pcVUI->getFrameFieldInfoPresentFlag(), "frame_field_info_present_flag"); |
---|
| 599 | |
---|
| 600 | Window defaultDisplayWindow = pcVUI->getDefaultDisplayWindow(); |
---|
| 601 | WRITE_FLAG(defaultDisplayWindow.getWindowEnabledFlag(), "default_display_window_flag"); |
---|
| 602 | if( defaultDisplayWindow.getWindowEnabledFlag() ) |
---|
| 603 | { |
---|
[1084] | 604 | WRITE_UVLC(defaultDisplayWindow.getWindowLeftOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc()), "def_disp_win_left_offset"); |
---|
| 605 | WRITE_UVLC(defaultDisplayWindow.getWindowRightOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc()), "def_disp_win_right_offset"); |
---|
| 606 | WRITE_UVLC(defaultDisplayWindow.getWindowTopOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc()), "def_disp_win_top_offset"); |
---|
| 607 | WRITE_UVLC(defaultDisplayWindow.getWindowBottomOffset()/ TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc()), "def_disp_win_bottom_offset"); |
---|
[608] | 608 | } |
---|
[1200] | 609 | const TimingInfo *timingInfo = pcVUI->getTimingInfo(); |
---|
[608] | 610 | WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(), "vui_timing_info_present_flag"); |
---|
| 611 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
| 612 | { |
---|
| 613 | WRITE_CODE(timingInfo->getNumUnitsInTick(), 32, "vui_num_units_in_tick"); |
---|
| 614 | WRITE_CODE(timingInfo->getTimeScale(), 32, "vui_time_scale"); |
---|
| 615 | WRITE_FLAG(timingInfo->getPocProportionalToTimingFlag(), "vui_poc_proportional_to_timing_flag"); |
---|
| 616 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
[210] | 617 | { |
---|
[608] | 618 | WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(), "vui_num_ticks_poc_diff_one_minus1"); |
---|
| 619 | } |
---|
[1200] | 620 | WRITE_FLAG(pcVUI->getHrdParametersPresentFlag(), "vui_hrd_parameters_present_flag"); |
---|
| 621 | if( pcVUI->getHrdParametersPresentFlag() ) |
---|
| 622 | { |
---|
| 623 | codeHrdParameters(pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); |
---|
| 624 | } |
---|
[608] | 625 | } |
---|
| 626 | |
---|
| 627 | WRITE_FLAG(pcVUI->getBitstreamRestrictionFlag(), "bitstream_restriction_flag"); |
---|
| 628 | if (pcVUI->getBitstreamRestrictionFlag()) |
---|
| 629 | { |
---|
| 630 | WRITE_FLAG(pcVUI->getTilesFixedStructureFlag(), "tiles_fixed_structure_flag"); |
---|
| 631 | WRITE_FLAG(pcVUI->getMotionVectorsOverPicBoundariesFlag(), "motion_vectors_over_pic_boundaries_flag"); |
---|
| 632 | WRITE_FLAG(pcVUI->getRestrictedRefPicListsFlag(), "restricted_ref_pic_lists_flag"); |
---|
| 633 | WRITE_UVLC(pcVUI->getMinSpatialSegmentationIdc(), "min_spatial_segmentation_idc"); |
---|
| 634 | WRITE_UVLC(pcVUI->getMaxBytesPerPicDenom(), "max_bytes_per_pic_denom"); |
---|
[1200] | 635 | WRITE_UVLC(pcVUI->getMaxBitsPerMinCuDenom(), "max_bits_per_min_cu_denom"); |
---|
[608] | 636 | WRITE_UVLC(pcVUI->getLog2MaxMvLengthHorizontal(), "log2_max_mv_length_horizontal"); |
---|
| 637 | WRITE_UVLC(pcVUI->getLog2MaxMvLengthVertical(), "log2_max_mv_length_vertical"); |
---|
| 638 | } |
---|
| 639 | } |
---|
| 640 | |
---|
[1200] | 641 | Void TEncCavlc::codeHrdParameters( const TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 ) |
---|
[608] | 642 | { |
---|
| 643 | if( commonInfPresentFlag ) |
---|
| 644 | { |
---|
| 645 | WRITE_FLAG( hrd->getNalHrdParametersPresentFlag() ? 1 : 0 , "nal_hrd_parameters_present_flag" ); |
---|
| 646 | WRITE_FLAG( hrd->getVclHrdParametersPresentFlag() ? 1 : 0 , "vcl_hrd_parameters_present_flag" ); |
---|
| 647 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
| 648 | { |
---|
[1200] | 649 | WRITE_FLAG( hrd->getSubPicCpbParamsPresentFlag() ? 1 : 0, "sub_pic_hrd_params_present_flag" ); |
---|
[608] | 650 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
[210] | 651 | { |
---|
[608] | 652 | WRITE_CODE( hrd->getTickDivisorMinus2(), 8, "tick_divisor_minus2" ); |
---|
[1200] | 653 | WRITE_CODE( hrd->getDuCpbRemovalDelayLengthMinus1(), 5, "du_cpb_removal_delay_increment_length_minus1" ); |
---|
[608] | 654 | WRITE_FLAG( hrd->getSubPicCpbParamsInPicTimingSEIFlag() ? 1 : 0, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); |
---|
| 655 | WRITE_CODE( hrd->getDpbOutputDelayDuLengthMinus1(), 5, "dpb_output_delay_du_length_minus1" ); |
---|
[210] | 656 | } |
---|
[608] | 657 | WRITE_CODE( hrd->getBitRateScale(), 4, "bit_rate_scale" ); |
---|
| 658 | WRITE_CODE( hrd->getCpbSizeScale(), 4, "cpb_size_scale" ); |
---|
| 659 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 660 | { |
---|
[1200] | 661 | WRITE_CODE( hrd->getDuCpbSizeScale(), 4, "du_cpb_size_scale" ); |
---|
[608] | 662 | } |
---|
| 663 | WRITE_CODE( hrd->getInitialCpbRemovalDelayLengthMinus1(), 5, "initial_cpb_removal_delay_length_minus1" ); |
---|
| 664 | WRITE_CODE( hrd->getCpbRemovalDelayLengthMinus1(), 5, "au_cpb_removal_delay_length_minus1" ); |
---|
| 665 | WRITE_CODE( hrd->getDpbOutputDelayLengthMinus1(), 5, "dpb_output_delay_length_minus1" ); |
---|
[210] | 666 | } |
---|
| 667 | } |
---|
[608] | 668 | Int i, j, nalOrVcl; |
---|
| 669 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
[210] | 670 | { |
---|
[608] | 671 | WRITE_FLAG( hrd->getFixedPicRateFlag( i ) ? 1 : 0, "fixed_pic_rate_general_flag"); |
---|
[1200] | 672 | Bool fixedPixRateWithinCvsFlag = true; |
---|
[608] | 673 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
[210] | 674 | { |
---|
[1200] | 675 | fixedPixRateWithinCvsFlag = hrd->getFixedPicRateWithinCvsFlag( i ); |
---|
[608] | 676 | WRITE_FLAG( hrd->getFixedPicRateWithinCvsFlag( i ) ? 1 : 0, "fixed_pic_rate_within_cvs_flag"); |
---|
[210] | 677 | } |
---|
[1200] | 678 | if( fixedPixRateWithinCvsFlag ) |
---|
[210] | 679 | { |
---|
[608] | 680 | WRITE_UVLC( hrd->getPicDurationInTcMinus1( i ), "elemental_duration_in_tc_minus1"); |
---|
[210] | 681 | } |
---|
[608] | 682 | else |
---|
[210] | 683 | { |
---|
[608] | 684 | WRITE_FLAG( hrd->getLowDelayHrdFlag( i ) ? 1 : 0, "low_delay_hrd_flag"); |
---|
[210] | 685 | } |
---|
[608] | 686 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
| 687 | { |
---|
| 688 | WRITE_UVLC( hrd->getCpbCntMinus1( i ), "cpb_cnt_minus1"); |
---|
| 689 | } |
---|
[1200] | 690 | |
---|
[608] | 691 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
[77] | 692 | { |
---|
[608] | 693 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
| 694 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
[77] | 695 | { |
---|
[608] | 696 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
[77] | 697 | { |
---|
[608] | 698 | WRITE_UVLC( hrd->getBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_value_minus1"); |
---|
| 699 | WRITE_UVLC( hrd->getCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_value_minus1"); |
---|
| 700 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 701 | { |
---|
[1200] | 702 | WRITE_UVLC( hrd->getDuCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_du_value_minus1"); |
---|
[608] | 703 | WRITE_UVLC( hrd->getDuBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_du_value_minus1"); |
---|
| 704 | } |
---|
| 705 | WRITE_FLAG( hrd->getCbrFlag( i, j, nalOrVcl ) ? 1 : 0, "cbr_flag"); |
---|
[77] | 706 | } |
---|
| 707 | } |
---|
| 708 | } |
---|
| 709 | } |
---|
| 710 | } |
---|
[608] | 711 | |
---|
[1200] | 712 | Void TEncCavlc::codeSPS( const TComSPS* pcSPS ) |
---|
[56] | 713 | { |
---|
[1200] | 714 | |
---|
| 715 | const ChromaFormat format = pcSPS->getChromaFormatIdc(); |
---|
| 716 | const Bool chromaEnabled = isChromaEnabled(format); |
---|
| 717 | |
---|
| 718 | #if ENC_DEC_TRACE |
---|
| 719 | #if H_MV_ENC_DEC_TRAC |
---|
| 720 | tracePSHeader( "SPS", pcSPS->getLayerId() ); |
---|
| 721 | #else |
---|
| 722 | xTraceSPSHeader (); |
---|
[2] | 723 | #endif |
---|
[1200] | 724 | #endif |
---|
[608] | 725 | WRITE_CODE( pcSPS->getVPSId (), 4, "sps_video_parameter_set_id" ); |
---|
[1200] | 726 | #if NH_MV |
---|
[608] | 727 | if ( pcSPS->getLayerId() == 0 ) |
---|
| 728 | { |
---|
[77] | 729 | #endif |
---|
[608] | 730 | WRITE_CODE( pcSPS->getMaxTLayers() - 1, 3, "sps_max_sub_layers_minus1" ); |
---|
[1200] | 731 | #if NH_MV |
---|
[1066] | 732 | } |
---|
| 733 | else |
---|
| 734 | { |
---|
| 735 | WRITE_CODE( pcSPS->getSpsExtOrMaxSubLayersMinus1( ), 3, "sps_ext_or_max_sub_layers_minus1" ); |
---|
| 736 | } |
---|
| 737 | if ( !pcSPS->getMultiLayerExtSpsFlag() ) |
---|
| 738 | { |
---|
| 739 | #endif |
---|
[1200] | 740 | WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0, "sps_temporal_id_nesting_flag" ); |
---|
[608] | 741 | codePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
[1200] | 742 | #if NH_MV |
---|
[608] | 743 | } |
---|
| 744 | #endif |
---|
| 745 | WRITE_UVLC( pcSPS->getSPSId (), "sps_seq_parameter_set_id" ); |
---|
[1200] | 746 | #if NH_MV |
---|
[1066] | 747 | if ( pcSPS->getMultiLayerExtSpsFlag() ) |
---|
[622] | 748 | { |
---|
| 749 | WRITE_FLAG( pcSPS->getUpdateRepFormatFlag( ) ? 1 : 0 , "update_rep_format_flag" ); |
---|
[738] | 750 | if ( pcSPS->getUpdateRepFormatFlag() ) |
---|
| 751 | { |
---|
| 752 | WRITE_CODE( pcSPS->getSpsRepFormatIdx( ), 8, "sps_rep_format_idx" ); |
---|
| 753 | } |
---|
[622] | 754 | } |
---|
[738] | 755 | else |
---|
| 756 | { |
---|
[622] | 757 | #endif |
---|
[1200] | 758 | WRITE_UVLC( Int(pcSPS->getChromaFormatIdc ()), "chroma_format_idc" ); |
---|
| 759 | if( format == CHROMA_444 ) |
---|
[2] | 760 | { |
---|
[608] | 761 | WRITE_FLAG( 0, "separate_colour_plane_flag"); |
---|
[2] | 762 | } |
---|
| 763 | |
---|
[608] | 764 | WRITE_UVLC( pcSPS->getPicWidthInLumaSamples (), "pic_width_in_luma_samples" ); |
---|
| 765 | WRITE_UVLC( pcSPS->getPicHeightInLumaSamples(), "pic_height_in_luma_samples" ); |
---|
| 766 | Window conf = pcSPS->getConformanceWindow(); |
---|
[2] | 767 | |
---|
[608] | 768 | WRITE_FLAG( conf.getWindowEnabledFlag(), "conformance_window_flag" ); |
---|
| 769 | if (conf.getWindowEnabledFlag()) |
---|
[2] | 770 | { |
---|
[608] | 771 | WRITE_UVLC( conf.getWindowLeftOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_left_offset" ); |
---|
| 772 | WRITE_UVLC( conf.getWindowRightOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_right_offset" ); |
---|
| 773 | WRITE_UVLC( conf.getWindowTopOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_top_offset" ); |
---|
| 774 | WRITE_UVLC( conf.getWindowBottomOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_bottom_offset" ); |
---|
[2] | 775 | } |
---|
[1200] | 776 | #if NH_MV |
---|
[1066] | 777 | } |
---|
| 778 | #endif |
---|
[1200] | 779 | #if NH_MV |
---|
[1066] | 780 | if ( !pcSPS->getMultiLayerExtSpsFlag() ) |
---|
[622] | 781 | { |
---|
| 782 | #endif |
---|
[1200] | 783 | |
---|
| 784 | WRITE_UVLC( pcSPS->getBitDepth(CHANNEL_TYPE_LUMA) - 8, "bit_depth_luma_minus8" ); |
---|
| 785 | |
---|
| 786 | WRITE_UVLC( chromaEnabled ? (pcSPS->getBitDepth(CHANNEL_TYPE_CHROMA) - 8):0, "bit_depth_chroma_minus8" ); |
---|
| 787 | #if NH_MV |
---|
[622] | 788 | } |
---|
| 789 | #endif |
---|
[56] | 790 | WRITE_UVLC( pcSPS->getBitsForPOC()-4, "log2_max_pic_order_cnt_lsb_minus4" ); |
---|
[1200] | 791 | #if NH_MV |
---|
[1066] | 792 | if ( !pcSPS->getMultiLayerExtSpsFlag()) |
---|
[872] | 793 | { |
---|
| 794 | #endif |
---|
[1200] | 795 | |
---|
[608] | 796 | const Bool subLayerOrderingInfoPresentFlag = 1; |
---|
| 797 | WRITE_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); |
---|
[56] | 798 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
[2] | 799 | { |
---|
[608] | 800 | WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i) - 1, "sps_max_dec_pic_buffering_minus1[i]" ); |
---|
[1200] | 801 | WRITE_UVLC( pcSPS->getNumReorderPics(i), "sps_max_num_reorder_pics[i]" ); |
---|
[608] | 802 | WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i), "sps_max_latency_increase_plus1[i]" ); |
---|
| 803 | if (!subLayerOrderingInfoPresentFlag) |
---|
| 804 | { |
---|
| 805 | break; |
---|
| 806 | } |
---|
[2] | 807 | } |
---|
[1200] | 808 | #if NH_MV |
---|
[872] | 809 | } |
---|
| 810 | #endif |
---|
| 811 | |
---|
[56] | 812 | assert( pcSPS->getMaxCUWidth() == pcSPS->getMaxCUHeight() ); |
---|
[1200] | 813 | WRITE_UVLC( pcSPS->getLog2MinCodingBlockSize() - 3, "log2_min_luma_coding_block_size_minus3" ); |
---|
| 814 | WRITE_UVLC( pcSPS->getLog2DiffMaxMinCodingBlockSize(), "log2_diff_max_min_luma_coding_block_size" ); |
---|
| 815 | WRITE_UVLC( pcSPS->getQuadtreeTULog2MinSize() - 2, "log2_min_luma_transform_block_size_minus2" ); |
---|
| 816 | WRITE_UVLC( pcSPS->getQuadtreeTULog2MaxSize() - pcSPS->getQuadtreeTULog2MinSize(), "log2_diff_max_min_luma_transform_block_size" ); |
---|
[56] | 817 | WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthInter() - 1, "max_transform_hierarchy_depth_inter" ); |
---|
| 818 | WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthIntra() - 1, "max_transform_hierarchy_depth_intra" ); |
---|
[1200] | 819 | WRITE_FLAG( pcSPS->getScalingListFlag() ? 1 : 0, "scaling_list_enabled_flag" ); |
---|
[608] | 820 | if(pcSPS->getScalingListFlag()) |
---|
[2] | 821 | { |
---|
[1200] | 822 | #if NH_MV |
---|
[1066] | 823 | if ( pcSPS->getMultiLayerExtSpsFlag() ) |
---|
[622] | 824 | { |
---|
| 825 | WRITE_FLAG( pcSPS->getSpsInferScalingListFlag( ) ? 1 : 0 , "sps_infer_scaling_list_flag" ); |
---|
| 826 | } |
---|
| 827 | |
---|
| 828 | if ( pcSPS->getSpsInferScalingListFlag() ) |
---|
| 829 | { |
---|
| 830 | WRITE_CODE( pcSPS->getSpsScalingListRefLayerId( ), 6, "sps_scaling_list_ref_layer_id" ); |
---|
| 831 | } |
---|
| 832 | else |
---|
| 833 | { |
---|
| 834 | #endif |
---|
[1200] | 835 | |
---|
| 836 | WRITE_FLAG( pcSPS->getScalingListPresentFlag() ? 1 : 0, "sps_scaling_list_data_present_flag" ); |
---|
[608] | 837 | if(pcSPS->getScalingListPresentFlag()) |
---|
| 838 | { |
---|
[1200] | 839 | codeScalingList( pcSPS->getScalingList() ); |
---|
[608] | 840 | } |
---|
[1200] | 841 | #if NH_MV |
---|
[622] | 842 | } |
---|
| 843 | #endif |
---|
[2] | 844 | } |
---|
[608] | 845 | WRITE_FLAG( pcSPS->getUseAMP() ? 1 : 0, "amp_enabled_flag" ); |
---|
| 846 | WRITE_FLAG( pcSPS->getUseSAO() ? 1 : 0, "sample_adaptive_offset_enabled_flag"); |
---|
[2] | 847 | |
---|
[608] | 848 | WRITE_FLAG( pcSPS->getUsePCM() ? 1 : 0, "pcm_enabled_flag"); |
---|
[56] | 849 | if( pcSPS->getUsePCM() ) |
---|
[2] | 850 | { |
---|
[1200] | 851 | WRITE_CODE( pcSPS->getPCMBitDepth(CHANNEL_TYPE_LUMA) - 1, 4, "pcm_sample_bit_depth_luma_minus1" ); |
---|
| 852 | WRITE_CODE( chromaEnabled ? (pcSPS->getPCMBitDepth(CHANNEL_TYPE_CHROMA) - 1) : 0, 4, "pcm_sample_bit_depth_chroma_minus1" ); |
---|
[608] | 853 | WRITE_UVLC( pcSPS->getPCMLog2MinSize() - 3, "log2_min_pcm_luma_coding_block_size_minus3" ); |
---|
| 854 | WRITE_UVLC( pcSPS->getPCMLog2MaxSize() - pcSPS->getPCMLog2MinSize(), "log2_diff_max_min_pcm_luma_coding_block_size" ); |
---|
| 855 | WRITE_FLAG( pcSPS->getPCMFilterDisableFlag()?1 : 0, "pcm_loop_filter_disable_flag"); |
---|
[2] | 856 | } |
---|
| 857 | |
---|
[1200] | 858 | assert( pcSPS->getMaxTLayers() > 0 ); |
---|
[2] | 859 | |
---|
[1200] | 860 | const TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
[2] | 861 | |
---|
[56] | 862 | WRITE_UVLC(rpsList->getNumberOfReferencePictureSets(), "num_short_term_ref_pic_sets" ); |
---|
| 863 | for(Int i=0; i < rpsList->getNumberOfReferencePictureSets(); i++) |
---|
[2] | 864 | { |
---|
[1200] | 865 | const TComReferencePictureSet*rps = rpsList->getReferencePictureSet(i); |
---|
| 866 | codeShortTermRefPicSet( rps,false, i); |
---|
[608] | 867 | } |
---|
[56] | 868 | WRITE_FLAG( pcSPS->getLongTermRefsPresent() ? 1 : 0, "long_term_ref_pics_present_flag" ); |
---|
[1200] | 869 | if (pcSPS->getLongTermRefsPresent()) |
---|
[2] | 870 | { |
---|
[1200] | 871 | WRITE_UVLC(pcSPS->getNumLongTermRefPicSPS(), "num_long_term_ref_pics_sps" ); |
---|
[608] | 872 | for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) |
---|
| 873 | { |
---|
| 874 | WRITE_CODE( pcSPS->getLtRefPicPocLsbSps(k), pcSPS->getBitsForPOC(), "lt_ref_pic_poc_lsb_sps"); |
---|
[1200] | 875 | WRITE_FLAG( pcSPS->getUsedByCurrPicLtSPSFlag(k), "used_by_curr_pic_lt_sps_flag[i]"); |
---|
[608] | 876 | } |
---|
[2] | 877 | } |
---|
[608] | 878 | WRITE_FLAG( pcSPS->getTMVPFlagsPresent() ? 1 : 0, "sps_temporal_mvp_enable_flag" ); |
---|
[2] | 879 | |
---|
[608] | 880 | WRITE_FLAG( pcSPS->getUseStrongIntraSmoothing(), "sps_strong_intra_smoothing_enable_flag" ); |
---|
| 881 | |
---|
| 882 | WRITE_FLAG( pcSPS->getVuiParametersPresentFlag(), "vui_parameters_present_flag" ); |
---|
| 883 | if (pcSPS->getVuiParametersPresentFlag()) |
---|
[2] | 884 | { |
---|
[608] | 885 | codeVUI(pcSPS->getVuiParameters(), pcSPS); |
---|
[2] | 886 | } |
---|
[608] | 887 | |
---|
[1200] | 888 | #if !NH_MV |
---|
| 889 | Bool sps_extension_present_flag=false; |
---|
| 890 | Bool sps_extension_flags[NUM_SPS_EXTENSION_FLAGS]={false}; |
---|
| 891 | |
---|
| 892 | sps_extension_flags[SPS_EXT__REXT] = pcSPS->getSpsRangeExtension().settingsDifferFromDefaults(); |
---|
| 893 | |
---|
| 894 | // Other SPS extension flags checked here. |
---|
| 895 | |
---|
| 896 | for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) |
---|
| 897 | { |
---|
| 898 | sps_extension_present_flag|=sps_extension_flags[i]; |
---|
| 899 | } |
---|
| 900 | |
---|
| 901 | WRITE_FLAG( (sps_extension_present_flag?1:0), "sps_extension_present_flag" ); |
---|
| 902 | |
---|
| 903 | if (sps_extension_present_flag) |
---|
| 904 | { |
---|
| 905 | #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
| 906 | static const char *syntaxStrings[]={ "sps_range_extension_flag", |
---|
| 907 | "sps_multilayer_extension_flag", |
---|
| 908 | "sps_extension_6bits[0]", |
---|
| 909 | "sps_extension_6bits[1]", |
---|
| 910 | "sps_extension_6bits[2]", |
---|
| 911 | "sps_extension_6bits[3]", |
---|
| 912 | "sps_extension_6bits[4]", |
---|
| 913 | "sps_extension_6bits[5]" }; |
---|
| 914 | #endif |
---|
| 915 | |
---|
| 916 | for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) |
---|
| 917 | { |
---|
| 918 | WRITE_FLAG( sps_extension_flags[i]?1:0, syntaxStrings[i] ); |
---|
| 919 | } |
---|
| 920 | |
---|
| 921 | for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. |
---|
| 922 | { |
---|
| 923 | if (sps_extension_flags[i]) |
---|
| 924 | { |
---|
| 925 | switch (SPSExtensionFlagIndex(i)) |
---|
| 926 | { |
---|
| 927 | case SPS_EXT__REXT: |
---|
| 928 | { |
---|
| 929 | const TComSPSRExt &spsRangeExtension=pcSPS->getSpsRangeExtension(); |
---|
| 930 | |
---|
| 931 | WRITE_FLAG( (spsRangeExtension.getTransformSkipRotationEnabledFlag() ? 1 : 0), "transform_skip_rotation_enabled_flag"); |
---|
| 932 | WRITE_FLAG( (spsRangeExtension.getTransformSkipContextEnabledFlag() ? 1 : 0), "transform_skip_context_enabled_flag"); |
---|
| 933 | WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT) ? 1 : 0), "implicit_rdpcm_enabled_flag" ); |
---|
| 934 | WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT) ? 1 : 0), "explicit_rdpcm_enabled_flag" ); |
---|
| 935 | WRITE_FLAG( (spsRangeExtension.getExtendedPrecisionProcessingFlag() ? 1 : 0), "extended_precision_processing_flag" ); |
---|
| 936 | WRITE_FLAG( (spsRangeExtension.getIntraSmoothingDisabledFlag() ? 1 : 0), "intra_smoothing_disabled_flag" ); |
---|
| 937 | WRITE_FLAG( (spsRangeExtension.getHighPrecisionOffsetsEnabledFlag() ? 1 : 0), "high_precision_offsets_enabled_flag" ); |
---|
| 938 | WRITE_FLAG( (spsRangeExtension.getPersistentRiceAdaptationEnabledFlag() ? 1 : 0), "persistent_rice_adaptation_enabled_flag" ); |
---|
| 939 | WRITE_FLAG( (spsRangeExtension.getCabacBypassAlignmentEnabledFlag() ? 1 : 0), "cabac_bypass_alignment_enabled_flag" ); |
---|
| 940 | break; |
---|
| 941 | } |
---|
| 942 | default: |
---|
| 943 | assert(sps_extension_flags[i]==false); // Should never get here with an active SPS extension flag. |
---|
| 944 | break; |
---|
| 945 | } |
---|
| 946 | } |
---|
| 947 | } |
---|
| 948 | } |
---|
[622] | 949 | #else |
---|
[964] | 950 | WRITE_FLAG( pcSPS->getSpsExtensionPresentFlag(), "sps_extension_present_flag" ); |
---|
[738] | 951 | |
---|
[964] | 952 | if ( pcSPS->getSpsExtensionPresentFlag() ) |
---|
[738] | 953 | { |
---|
[1200] | 954 | WRITE_FLAG( pcSPS->getSpsRangeExtensionsFlag( ) ? 1 : 0 , "sps_range_extensions_flag" ); |
---|
[964] | 955 | WRITE_FLAG( pcSPS->getSpsMultilayerExtensionFlag( ) ? 1 : 0 , "sps_multilayer_extension_flag" ); |
---|
[1200] | 956 | WRITE_FLAG( pcSPS->getSps3dExtensionFlag( ) ? 1 : 0 , "sps_3d_extension_flag" ); |
---|
| 957 | WRITE_CODE( pcSPS->getSpsExtension5bits( ) , 5 , "sps_extension_5bits" ); |
---|
[976] | 958 | } |
---|
[964] | 959 | |
---|
| 960 | if ( pcSPS->getSpsRangeExtensionsFlag() ) |
---|
| 961 | { |
---|
[1200] | 962 | const TComSPSRExt &spsRangeExtension=pcSPS->getSpsRangeExtension(); |
---|
| 963 | |
---|
| 964 | WRITE_FLAG( (spsRangeExtension.getTransformSkipRotationEnabledFlag() ? 1 : 0), "transform_skip_rotation_enabled_flag"); |
---|
| 965 | WRITE_FLAG( (spsRangeExtension.getTransformSkipContextEnabledFlag() ? 1 : 0), "transform_skip_context_enabled_flag"); |
---|
| 966 | WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT) ? 1 : 0), "implicit_rdpcm_enabled_flag" ); |
---|
| 967 | WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT) ? 1 : 0), "explicit_rdpcm_enabled_flag" ); |
---|
| 968 | WRITE_FLAG( (spsRangeExtension.getExtendedPrecisionProcessingFlag() ? 1 : 0), "extended_precision_processing_flag" ); |
---|
| 969 | WRITE_FLAG( (spsRangeExtension.getIntraSmoothingDisabledFlag() ? 1 : 0), "intra_smoothing_disabled_flag" ); |
---|
| 970 | WRITE_FLAG( (spsRangeExtension.getHighPrecisionOffsetsEnabledFlag() ? 1 : 0), "high_precision_offsets_enabled_flag" ); |
---|
| 971 | WRITE_FLAG( (spsRangeExtension.getPersistentRiceAdaptationEnabledFlag() ? 1 : 0), "persistent_rice_adaptation_enabled_flag" ); |
---|
| 972 | WRITE_FLAG( (spsRangeExtension.getCabacBypassAlignmentEnabledFlag() ? 1 : 0), "cabac_bypass_alignment_enabled_flag" ); |
---|
[964] | 973 | } |
---|
| 974 | |
---|
| 975 | if ( pcSPS->getSpsMultilayerExtensionFlag() ) |
---|
| 976 | { |
---|
| 977 | codeSPSExtension( pcSPS ); |
---|
| 978 | } |
---|
| 979 | |
---|
[1200] | 980 | #if NH_3D |
---|
[964] | 981 | if ( pcSPS->getSps3dExtensionFlag() ) |
---|
| 982 | { |
---|
[1124] | 983 | codeSPS3dExtension( pcSPS ); |
---|
[964] | 984 | } |
---|
| 985 | |
---|
| 986 | #endif |
---|
[738] | 987 | #endif |
---|
[1200] | 988 | xWriteRbspTrailingBits(); |
---|
[622] | 989 | } |
---|
[608] | 990 | |
---|
[1200] | 991 | #if NH_MV |
---|
| 992 | Void TEncCavlc::codeSPSExtension( const TComSPS* pcSPS ) |
---|
[622] | 993 | { |
---|
| 994 | WRITE_FLAG( pcSPS->getInterViewMvVertConstraintFlag() ? 1 : 0, "inter_view_mv_vert_constraint_flag" ); |
---|
| 995 | } |
---|
[1066] | 996 | |
---|
| 997 | |
---|
[1200] | 998 | Void TEncCavlc::codePpsMultilayerExtension(const TComPPS* pcPPS) |
---|
[1066] | 999 | { |
---|
| 1000 | WRITE_FLAG( pcPPS->getPocResetInfoPresentFlag( ) ? 1 : 0 , "poc_reset_info_present_flag" ); |
---|
| 1001 | WRITE_FLAG( pcPPS->getPpsInferScalingListFlag( ) ? 1 : 0 , "pps_infer_scaling_list_flag" ); |
---|
[1179] | 1002 | if (pcPPS->getPpsInferScalingListFlag()) |
---|
| 1003 | { |
---|
| 1004 | WRITE_CODE( pcPPS->getPpsScalingListRefLayerId( ), 6, "pps_scaling_list_ref_layer_id" ); |
---|
| 1005 | } |
---|
[1066] | 1006 | WRITE_UVLC( 0, "num_ref_loc_offsets" ); |
---|
[1124] | 1007 | WRITE_FLAG( 0 , "colour_mapping_enabled_flag" ); |
---|
| 1008 | |
---|
[1066] | 1009 | } |
---|
[622] | 1010 | |
---|
[1066] | 1011 | #endif |
---|
| 1012 | |
---|
[1200] | 1013 | #if NH_3D |
---|
| 1014 | Void TEncCavlc::codeSPS3dExtension( const TComSPS* pcSPS ) |
---|
[1124] | 1015 | { |
---|
[1200] | 1016 | const TComSps3dExtension* sps3dExt = pcSPS->getSps3dExtension(); |
---|
[1124] | 1017 | for( Int d = 0; d <= 1; d++ ) |
---|
| 1018 | { |
---|
| 1019 | WRITE_FLAG( sps3dExt->getIvMvPredFlag( d ) ? 1 : 0 , "iv_mv_pred_flag" ); |
---|
| 1020 | WRITE_FLAG( sps3dExt->getIvMvScalingFlag( d ) ? 1 : 0 , "iv_mv_scaling_flag" ); |
---|
| 1021 | if( d == 0 ) |
---|
| 1022 | { |
---|
| 1023 | WRITE_UVLC( sps3dExt->getLog2SubPbSizeMinus3( d ), "log2_sub_pb_size_minus3" ); |
---|
| 1024 | WRITE_FLAG( sps3dExt->getIvResPredFlag( d ) ? 1 : 0 , "iv_res_pred_flag" ); |
---|
| 1025 | WRITE_FLAG( sps3dExt->getDepthRefinementFlag( d ) ? 1 : 0 , "depth_refinement_flag" ); |
---|
| 1026 | WRITE_FLAG( sps3dExt->getViewSynthesisPredFlag( d ) ? 1 : 0 , "view_synthesis_pred_flag" ); |
---|
| 1027 | WRITE_FLAG( sps3dExt->getDepthBasedBlkPartFlag( d ) ? 1 : 0 , "depth_based_blk_part_flag" ); |
---|
| 1028 | } |
---|
| 1029 | else |
---|
| 1030 | { |
---|
| 1031 | WRITE_FLAG( sps3dExt->getMpiFlag( d ) ? 1 : 0 , "mpi_flag" ); |
---|
| 1032 | WRITE_UVLC( sps3dExt->getLog2MpiSubPbSizeMinus3( d ), "log2_mpi_sub_pb_size_minus3" ); |
---|
| 1033 | WRITE_FLAG( sps3dExt->getIntraContourFlag( d ) ? 1 : 0 , "intra_contour_flag" ); |
---|
| 1034 | WRITE_FLAG( sps3dExt->getIntraSdcWedgeFlag( d ) ? 1 : 0 , "intra_sdc_wedge_flag" ); |
---|
| 1035 | WRITE_FLAG( sps3dExt->getQtPredFlag( d ) ? 1 : 0 , "qt_pred_flag" ); |
---|
| 1036 | WRITE_FLAG( sps3dExt->getInterSdcFlag( d ) ? 1 : 0 , "inter_sdc_flag" ); |
---|
[1179] | 1037 | WRITE_FLAG( sps3dExt->getDepthIntraSkipFlag( d ) ? 1 : 0 , "intra_skip_flag" ); |
---|
[1124] | 1038 | } |
---|
| 1039 | } |
---|
| 1040 | } |
---|
[622] | 1041 | #endif |
---|
[1066] | 1042 | |
---|
| 1043 | |
---|
[1200] | 1044 | Void TEncCavlc::codeVPS( const TComVPS* pcVPS ) |
---|
[608] | 1045 | { |
---|
[1200] | 1046 | #if ENC_DEC_TRACE |
---|
| 1047 | #if H_MV_ENC_DEC_TRAC |
---|
| 1048 | tracePSHeader( "VPS", getEncTop()->getLayerId() ); |
---|
| 1049 | #else |
---|
| 1050 | xTraceVPSHeader(); |
---|
| 1051 | #endif |
---|
| 1052 | #endif |
---|
[608] | 1053 | WRITE_CODE( pcVPS->getVPSId(), 4, "vps_video_parameter_set_id" ); |
---|
[1200] | 1054 | #if NH_MV |
---|
[964] | 1055 | WRITE_FLAG( pcVPS->getVpsBaseLayerInternalFlag( ) ? 1 : 0 , "vps_base_layer_internal_flag" ); |
---|
[1066] | 1056 | WRITE_FLAG( pcVPS->getVpsBaseLayerAvailableFlag( ) ? 1 : 0 , "vps_base_layer_available_flag" ); |
---|
[964] | 1057 | #else |
---|
[1200] | 1058 | WRITE_FLAG( 1, "vps_base_layer_internal_flag" ); |
---|
| 1059 | WRITE_FLAG( 1, "vps_base_layer_available_flag" ); |
---|
[964] | 1060 | #endif |
---|
[1200] | 1061 | #if NH_MV |
---|
[622] | 1062 | WRITE_CODE( pcVPS->getMaxLayersMinus1(), 6, "vps_max_layers_minus1" ); |
---|
| 1063 | #else |
---|
[1200] | 1064 | WRITE_CODE( 0, 6, "vps_max_layers_minus1" ); |
---|
[608] | 1065 | #endif |
---|
| 1066 | WRITE_CODE( pcVPS->getMaxTLayers() - 1, 3, "vps_max_sub_layers_minus1" ); |
---|
| 1067 | WRITE_FLAG( pcVPS->getTemporalNestingFlag(), "vps_temporal_id_nesting_flag" ); |
---|
| 1068 | assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); |
---|
[1200] | 1069 | WRITE_CODE( 0xffff, 16, "vps_reserved_0xffff_16bits" ); |
---|
[608] | 1070 | codePTL( pcVPS->getPTL(), true, pcVPS->getMaxTLayers() - 1 ); |
---|
| 1071 | const Bool subLayerOrderingInfoPresentFlag = 1; |
---|
| 1072 | WRITE_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); |
---|
| 1073 | for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
| 1074 | { |
---|
| 1075 | WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i) - 1, "vps_max_dec_pic_buffering_minus1[i]" ); |
---|
[1200] | 1076 | WRITE_UVLC( pcVPS->getNumReorderPics(i), "vps_max_num_reorder_pics[i]" ); |
---|
[608] | 1077 | WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i), "vps_max_latency_increase_plus1[i]" ); |
---|
| 1078 | if (!subLayerOrderingInfoPresentFlag) |
---|
[2] | 1079 | { |
---|
[608] | 1080 | break; |
---|
[2] | 1081 | } |
---|
| 1082 | } |
---|
[1200] | 1083 | |
---|
[608] | 1084 | assert( pcVPS->getNumHrdParameters() <= MAX_VPS_NUM_HRD_PARAMETERS ); |
---|
[1200] | 1085 | #if NH_MV |
---|
[608] | 1086 | assert( pcVPS->getVpsMaxLayerId() < MAX_VPS_NUH_LAYER_ID_PLUS1 ); |
---|
| 1087 | WRITE_CODE( pcVPS->getVpsMaxLayerId(), 6, "vps_max_layer_id" ); |
---|
[1066] | 1088 | WRITE_UVLC( pcVPS->getVpsNumLayerSetsMinus1(), "vps_num_layer_sets_minus1" ); |
---|
[608] | 1089 | for( UInt opsIdx = 1; opsIdx <= pcVPS->getVpsNumLayerSetsMinus1(); opsIdx ++ ) |
---|
[2] | 1090 | { |
---|
[608] | 1091 | // Operation point set |
---|
| 1092 | for( UInt i = 0; i <= pcVPS->getVpsMaxLayerId(); i ++ ) |
---|
| 1093 | { |
---|
| 1094 | #else |
---|
| 1095 | assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); |
---|
[1200] | 1096 | WRITE_CODE( pcVPS->getMaxNuhReservedZeroLayerId(), 6, "vps_max_layer_id" ); |
---|
| 1097 | WRITE_UVLC( pcVPS->getMaxOpSets() - 1, "vps_num_layer_sets_minus1" ); |
---|
[608] | 1098 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) |
---|
| 1099 | { |
---|
| 1100 | // Operation point set |
---|
| 1101 | for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) |
---|
| 1102 | { |
---|
| 1103 | // Only applicable for version 1 |
---|
[1200] | 1104 | // pcVPS->setLayerIdIncludedFlag( true, opsIdx, i ); |
---|
[608] | 1105 | #endif |
---|
| 1106 | WRITE_FLAG( pcVPS->getLayerIdIncludedFlag( opsIdx, i ) ? 1 : 0, "layer_id_included_flag[opsIdx][i]" ); |
---|
| 1107 | } |
---|
| 1108 | } |
---|
[1200] | 1109 | const TimingInfo *timingInfo = pcVPS->getTimingInfo(); |
---|
[608] | 1110 | WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(), "vps_timing_info_present_flag"); |
---|
| 1111 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
| 1112 | { |
---|
| 1113 | WRITE_CODE(timingInfo->getNumUnitsInTick(), 32, "vps_num_units_in_tick"); |
---|
| 1114 | WRITE_CODE(timingInfo->getTimeScale(), 32, "vps_time_scale"); |
---|
| 1115 | WRITE_FLAG(timingInfo->getPocProportionalToTimingFlag(), "vps_poc_proportional_to_timing_flag"); |
---|
| 1116 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
| 1117 | { |
---|
| 1118 | WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(), "vps_num_ticks_poc_diff_one_minus1"); |
---|
| 1119 | } |
---|
| 1120 | WRITE_UVLC( pcVPS->getNumHrdParameters(), "vps_num_hrd_parameters" ); |
---|
[56] | 1121 | |
---|
[608] | 1122 | if( pcVPS->getNumHrdParameters() > 0 ) |
---|
[56] | 1123 | { |
---|
[1200] | 1124 | for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) |
---|
[608] | 1125 | { |
---|
[1200] | 1126 | // Only applicable for version 1 |
---|
| 1127 | WRITE_UVLC( pcVPS->getHrdOpSetIdx( i ), "hrd_layer_set_idx" ); |
---|
| 1128 | if( i > 0 ) |
---|
| 1129 | { |
---|
| 1130 | WRITE_FLAG( pcVPS->getCprmsPresentFlag( i ) ? 1 : 0, "cprms_present_flag[i]" ); |
---|
| 1131 | } |
---|
| 1132 | codeHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); |
---|
[608] | 1133 | } |
---|
| 1134 | } |
---|
[2] | 1135 | } |
---|
[1200] | 1136 | #if NH_MV |
---|
[964] | 1137 | WRITE_FLAG( pcVPS->getVpsExtensionFlag(), "vps_extension_flag" ); |
---|
[622] | 1138 | m_pcBitIf->writeAlignOne(); |
---|
| 1139 | codeVPSExtension( pcVPS ); |
---|
[1200] | 1140 | #if NH_3D |
---|
[1124] | 1141 | WRITE_FLAG( 1, "vps_extension2_flag" ); |
---|
| 1142 | WRITE_FLAG( 1, "vps_3d_extension_flag" ); |
---|
[622] | 1143 | m_pcBitIf->writeAlignOne(); |
---|
[1124] | 1144 | codeVPS3dExtension( pcVPS ); |
---|
[622] | 1145 | WRITE_FLAG( 0, "vps_extension3_flag" ); |
---|
| 1146 | #else |
---|
| 1147 | WRITE_FLAG( 0, "vps_extension2_flag" ); |
---|
| 1148 | #endif |
---|
| 1149 | #else |
---|
| 1150 | WRITE_FLAG( 0, "vps_extension_flag" ); |
---|
| 1151 | #endif |
---|
[1200] | 1152 | |
---|
[622] | 1153 | //future extensions here.. |
---|
[1200] | 1154 | xWriteRbspTrailingBits(); |
---|
[622] | 1155 | } |
---|
[2] | 1156 | |
---|
[1200] | 1157 | #if NH_MV |
---|
| 1158 | Void TEncCavlc::codeVPSExtension( const TComVPS *pcVPS ) |
---|
[1066] | 1159 | { |
---|
| 1160 | if( pcVPS->getMaxLayersMinus1() > 0 && pcVPS->getVpsBaseLayerInternalFlag() ) |
---|
| 1161 | { |
---|
| 1162 | codePTL( pcVPS->getPTL( 1 ),0, pcVPS->getMaxSubLayersMinus1() ); |
---|
| 1163 | } |
---|
| 1164 | |
---|
[884] | 1165 | WRITE_FLAG( pcVPS->getSplittingFlag() ? 1 : 0, "splitting_flag" ); |
---|
[872] | 1166 | |
---|
[622] | 1167 | for( Int type = 0; type < MAX_NUM_SCALABILITY_TYPES; type++ ) |
---|
| 1168 | { |
---|
| 1169 | WRITE_FLAG( pcVPS->getScalabilityMaskFlag( type ) ? 1 : 0, "scalability_mask_flag[i]" ); |
---|
| 1170 | } |
---|
| 1171 | |
---|
| 1172 | for( Int sIdx = 0; sIdx < pcVPS->getNumScalabilityTypes( ) - ( pcVPS->getSplittingFlag() ? 1 : 0 ); sIdx++ ) |
---|
| 1173 | { |
---|
| 1174 | WRITE_CODE( pcVPS->getDimensionIdLen( sIdx ) - 1 , 3, "dimension_id_len_minus1[j]"); |
---|
| 1175 | } |
---|
| 1176 | |
---|
| 1177 | if ( pcVPS->getSplittingFlag() ) |
---|
[1200] | 1178 | { |
---|
| 1179 | assert( pcVPS->getDimensionIdLen( pcVPS->getNumScalabilityTypes( ) - 1 ) == pcVPS->inferLastDimsionIdLenMinus1() + 1 ); |
---|
[622] | 1180 | } |
---|
| 1181 | |
---|
| 1182 | WRITE_FLAG( pcVPS->getVpsNuhLayerIdPresentFlag() ? 1 : 0, "vps_nuh_layer_id_present_flag"); |
---|
| 1183 | |
---|
| 1184 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1185 | { |
---|
| 1186 | if ( pcVPS->getVpsNuhLayerIdPresentFlag() ) |
---|
| 1187 | { |
---|
| 1188 | WRITE_CODE( pcVPS->getLayerIdInNuh( i ), 6, "layer_id_in_nuh[i]"); |
---|
[884] | 1189 | } |
---|
[622] | 1190 | else |
---|
| 1191 | { |
---|
| 1192 | assert( pcVPS->getLayerIdInNuh( i ) == i ); |
---|
[884] | 1193 | } |
---|
[622] | 1194 | |
---|
| 1195 | assert( pcVPS->getLayerIdInVps( pcVPS->getLayerIdInNuh( i ) ) == i ); |
---|
| 1196 | |
---|
| 1197 | for( Int j = 0; j < pcVPS->getNumScalabilityTypes() ; j++ ) |
---|
| 1198 | { |
---|
| 1199 | if ( !pcVPS->getSplittingFlag() ) |
---|
| 1200 | { |
---|
| 1201 | WRITE_CODE( pcVPS->getDimensionId( i, j ), pcVPS->getDimensionIdLen( j ), "dimension_id[i][j]"); |
---|
| 1202 | } |
---|
| 1203 | else |
---|
| 1204 | { |
---|
| 1205 | assert( pcVPS->getDimensionId( i, j ) == pcVPS->inferDimensionId( i, j ) ); |
---|
| 1206 | } |
---|
| 1207 | } |
---|
| 1208 | } |
---|
| 1209 | |
---|
[884] | 1210 | WRITE_CODE( pcVPS->getViewIdLen( ), 4, "view_id_len" ); |
---|
| 1211 | |
---|
| 1212 | if ( pcVPS->getViewIdLen( ) > 0 ) |
---|
| 1213 | { |
---|
| 1214 | for( Int i = 0; i < pcVPS->getNumViews(); i++ ) |
---|
| 1215 | { |
---|
| 1216 | WRITE_CODE( pcVPS->getViewIdVal( i ), pcVPS->getViewIdLen( ), "view_id_val[i]" ); |
---|
[738] | 1217 | } |
---|
[884] | 1218 | } |
---|
| 1219 | else |
---|
| 1220 | { |
---|
| 1221 | for( Int i = 0; i < pcVPS->getNumViews(); i++ ) |
---|
[738] | 1222 | { |
---|
[884] | 1223 | assert( pcVPS->getViewIdVal( i ) == 0 ); |
---|
[738] | 1224 | } |
---|
[884] | 1225 | } |
---|
[622] | 1226 | |
---|
| 1227 | |
---|
| 1228 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1229 | { |
---|
| 1230 | for( Int j = 0; j < i; j++ ) |
---|
| 1231 | { |
---|
| 1232 | WRITE_FLAG( pcVPS->getDirectDependencyFlag( i, j ), "direct_dependency_flag[i][j]" ); |
---|
| 1233 | } |
---|
| 1234 | } |
---|
[964] | 1235 | |
---|
[1066] | 1236 | if ( pcVPS->getNumIndependentLayers() > 1 ) |
---|
| 1237 | { |
---|
| 1238 | WRITE_UVLC( pcVPS->getNumAddLayerSets( ), "num_add_layer_sets" ); |
---|
| 1239 | } |
---|
| 1240 | for (Int i = 0; i < pcVPS->getNumAddLayerSets(); i++) |
---|
| 1241 | { |
---|
| 1242 | for (Int j = 1; j < pcVPS->getNumIndependentLayers(); j++) |
---|
| 1243 | { |
---|
| 1244 | WRITE_CODE( pcVPS->getHighestLayerIdxPlus1( i, j ), pcVPS->getHighestLayerIdxPlus1Len( j ) , "highest_layer_idx_plus1" ); |
---|
| 1245 | } |
---|
| 1246 | |
---|
| 1247 | } |
---|
| 1248 | |
---|
| 1249 | |
---|
[738] | 1250 | WRITE_FLAG( pcVPS->getVpsSubLayersMaxMinus1PresentFlag( ) ? 1 : 0 , "vps_sub_layers_max_minus1_present_flag" ); |
---|
| 1251 | if ( pcVPS->getVpsSubLayersMaxMinus1PresentFlag() ) |
---|
| 1252 | { |
---|
[872] | 1253 | for (Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
[738] | 1254 | { |
---|
| 1255 | WRITE_CODE( pcVPS->getSubLayersVpsMaxMinus1( i ), 3, "sub_layers_vps_max_minus1" ); |
---|
| 1256 | pcVPS->checkSubLayersVpsMaxMinus1( i ); |
---|
| 1257 | } |
---|
| 1258 | } |
---|
| 1259 | else |
---|
| 1260 | { |
---|
[872] | 1261 | for (Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
[738] | 1262 | { |
---|
| 1263 | assert( pcVPS->getSubLayersVpsMaxMinus1( i ) + 1 == pcVPS->getMaxTLayers( ) ); |
---|
| 1264 | } |
---|
| 1265 | } |
---|
[622] | 1266 | WRITE_FLAG( pcVPS->getMaxTidRefPresentFlag( ) ? 1 : 0 , "max_tid_ref_present_flag" ); |
---|
| 1267 | |
---|
| 1268 | if ( pcVPS->getMaxTidRefPresentFlag() ) |
---|
| 1269 | { |
---|
| 1270 | for( Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1271 | { |
---|
[738] | 1272 | for( Int j = i + 1; j <= pcVPS->getMaxLayersMinus1(); j++ ) |
---|
| 1273 | { |
---|
| 1274 | if ( pcVPS->getDirectDependencyFlag(j,i) ) |
---|
| 1275 | { |
---|
| 1276 | WRITE_CODE( pcVPS->getMaxTidIlRefPicsPlus1( i, j ), 3, "max_tid_il_ref_pics_plus1" ); |
---|
| 1277 | } |
---|
| 1278 | } |
---|
[622] | 1279 | } |
---|
| 1280 | } |
---|
| 1281 | |
---|
| 1282 | WRITE_FLAG( pcVPS->getAllRefLayersActiveFlag( ) ? 1 : 0 , "all_ref_layers_active_flag" ); |
---|
[872] | 1283 | WRITE_UVLC( pcVPS->getVpsNumProfileTierLevelMinus1( ), "vps_num_profile_tier_level_minus1" ); |
---|
[622] | 1284 | |
---|
[1066] | 1285 | Int offsetVal = ( pcVPS->getMaxLayersMinus1() > 0 && pcVPS->getVpsBaseLayerInternalFlag() ) ? 2 : 1; |
---|
| 1286 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 2 : 1; i <= pcVPS->getVpsNumProfileTierLevelMinus1(); i++ ) |
---|
| 1287 | { |
---|
| 1288 | WRITE_FLAG( pcVPS->getVpsProfilePresentFlag( i ) ? 1 : 0, "vps_profile_present_flag[i]" ); |
---|
| 1289 | codePTL( pcVPS->getPTL( offsetVal ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers() - 1 ); |
---|
| 1290 | offsetVal++; |
---|
| 1291 | } |
---|
[622] | 1292 | |
---|
[1066] | 1293 | |
---|
[964] | 1294 | if (pcVPS->getNumLayerSets() > 1) |
---|
| 1295 | { |
---|
| 1296 | WRITE_UVLC( pcVPS->getNumAddOlss( ), "num_add_olss" ); |
---|
| 1297 | WRITE_CODE( pcVPS->getDefaultOutputLayerIdc( ), 2, "default_output_layer_idc" ); |
---|
| 1298 | } |
---|
[872] | 1299 | |
---|
[738] | 1300 | assert( pcVPS->getOutputLayerFlag(0, 0) == pcVPS->inferOutputLayerFlag( 0, 0 )); |
---|
[964] | 1301 | assert( pcVPS->getLayerSetIdxForOlsMinus1( 0 ) == -1 ); |
---|
[872] | 1302 | |
---|
[964] | 1303 | |
---|
[1066] | 1304 | if (pcVPS->getVpsBaseLayerInternalFlag() ) |
---|
| 1305 | { |
---|
| 1306 | assert( pcVPS->getProfileTierLevelIdx(0,0) == pcVPS->inferProfileTierLevelIdx(0,0) ); |
---|
| 1307 | } |
---|
[964] | 1308 | |
---|
| 1309 | |
---|
[872] | 1310 | for( Int i = 1; i < pcVPS->getNumOutputLayerSets( ); i++ ) |
---|
| 1311 | { |
---|
[1124] | 1312 | if( pcVPS->getNumLayerSets() > 2 && i >= pcVPS->getNumLayerSets( ) ) |
---|
[622] | 1313 | { |
---|
[1066] | 1314 | WRITE_CODE( pcVPS->getLayerSetIdxForOlsMinus1( i ), pcVPS->getLayerSetIdxForOlsMinus1Len( i ) , "layer_set_idx_for_ols_minus1[i]" ); |
---|
[872] | 1315 | } |
---|
| 1316 | |
---|
[964] | 1317 | if ( i > pcVPS->getVpsNumLayerSetsMinus1() || pcVPS->getDefaultOutputLayerIdc() == 2 ) |
---|
[872] | 1318 | { |
---|
[964] | 1319 | for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->olsIdxToLsIdx( i ) ); j++ ) |
---|
[872] | 1320 | { |
---|
| 1321 | WRITE_FLAG( pcVPS->getOutputLayerFlag( i, j) ? 1 : 0, "output_layer_flag" ); |
---|
| 1322 | } |
---|
| 1323 | } |
---|
| 1324 | else |
---|
| 1325 | { |
---|
[964] | 1326 | for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->olsIdxToLsIdx( i ) ) - 1; j++ ) |
---|
[872] | 1327 | { |
---|
| 1328 | assert( pcVPS->getOutputLayerFlag( i , j ) == pcVPS->inferOutputLayerFlag( i, j )); |
---|
| 1329 | } |
---|
| 1330 | } |
---|
[1066] | 1331 | |
---|
| 1332 | for ( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->olsIdxToLsIdx(i)); j++ ) |
---|
| 1333 | { |
---|
| 1334 | if (pcVPS->getNecessaryLayerFlag( i, j ) && pcVPS->getVpsNumProfileTierLevelMinus1() > 0 ) |
---|
| 1335 | { |
---|
| 1336 | WRITE_CODE( pcVPS->getProfileTierLevelIdx( i, j ), pcVPS->getProfileTierLevelIdxLen() ,"profile_tier_level_idx[ i ][ j ]" ); |
---|
| 1337 | } |
---|
| 1338 | if (pcVPS->getNecessaryLayerFlag( i, j ) && pcVPS->getVpsNumProfileTierLevelMinus1() == 0 ) |
---|
| 1339 | { |
---|
| 1340 | assert( pcVPS->getProfileTierLevelIdx( i , j ) == pcVPS->inferProfileTierLevelIdx( i, j ) ); |
---|
| 1341 | } |
---|
[872] | 1342 | |
---|
[1066] | 1343 | } |
---|
[872] | 1344 | if( pcVPS->getNumOutputLayersInOutputLayerSet( i ) == 1 && pcVPS->getNumDirectRefLayers( pcVPS->getOlsHighestOutputLayerId( i ) ) > 0 ) |
---|
| 1345 | { |
---|
| 1346 | WRITE_FLAG( pcVPS->getAltOutputLayerFlag( i ) ? 1 : 0 , "alt_output_layer_flag[ i ]" ); |
---|
| 1347 | } |
---|
[622] | 1348 | } |
---|
| 1349 | |
---|
[964] | 1350 | WRITE_UVLC( pcVPS->getVpsNumRepFormatsMinus1( ), "vps_num_rep_formats_minus1" ); |
---|
[622] | 1351 | |
---|
| 1352 | for (Int i = 0; i <= pcVPS->getVpsNumRepFormatsMinus1(); i++ ) |
---|
| 1353 | { |
---|
[1200] | 1354 | const TComRepFormat* curRepFormat = pcVPS->getRepFormat(i); |
---|
| 1355 | const TComRepFormat* prevRepFormat = i > 0 ? pcVPS->getRepFormat( i - 1) : NULL; |
---|
[738] | 1356 | codeRepFormat( i, curRepFormat , prevRepFormat); |
---|
[622] | 1357 | } |
---|
| 1358 | |
---|
[964] | 1359 | if ( pcVPS->getVpsNumRepFormatsMinus1() > 0 ) |
---|
| 1360 | { |
---|
| 1361 | WRITE_FLAG( pcVPS->getRepFormatIdxPresentFlag( ) ? 1 : 0 , "rep_format_idx_present_flag" ); |
---|
| 1362 | } |
---|
[976] | 1363 | |
---|
[622] | 1364 | if( pcVPS->getRepFormatIdxPresentFlag() ) |
---|
| 1365 | { |
---|
[964] | 1366 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
[622] | 1367 | { |
---|
[872] | 1368 | WRITE_CODE( pcVPS->getVpsRepFormatIdx(i), pcVPS->getVpsRepFormatIdxLen(), "vps_rep_format_idx[i]" ); |
---|
[622] | 1369 | } |
---|
| 1370 | } |
---|
[964] | 1371 | else |
---|
| 1372 | { |
---|
| 1373 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1374 | { |
---|
| 1375 | assert( pcVPS->getVpsRepFormatIdx( i ) == pcVPS->inferVpsRepFormatIdx( i ) ); |
---|
| 1376 | } |
---|
| 1377 | } |
---|
[622] | 1378 | |
---|
| 1379 | WRITE_FLAG( pcVPS->getMaxOneActiveRefLayerFlag( ) ? 1 : 0, "max_one_active_ref_layer_flag" ); |
---|
[872] | 1380 | WRITE_FLAG( pcVPS->getVpsPocLsbAlignedFlag( ) ? 1 : 0 , "vps_poc_lsb_aligned_flag" ); |
---|
[738] | 1381 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1382 | { |
---|
| 1383 | if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ) == 0 ) |
---|
| 1384 | { |
---|
| 1385 | WRITE_FLAG( pcVPS->getPocLsbNotPresentFlag( i ) ? 1 : 0 , "poc_lsb_not_present_flag" ); |
---|
| 1386 | } |
---|
| 1387 | } |
---|
[964] | 1388 | |
---|
[738] | 1389 | codeDpbSize( pcVPS ); |
---|
| 1390 | |
---|
[622] | 1391 | WRITE_UVLC( pcVPS->getDirectDepTypeLenMinus2 ( ), "direct_dep_type_len_minus2"); |
---|
| 1392 | |
---|
[738] | 1393 | WRITE_FLAG( pcVPS->getDefaultDirectDependencyFlag( ) ? 1 : 0 , "default_direct_dependency_flag" ); |
---|
| 1394 | if ( pcVPS->getDefaultDirectDependencyFlag( ) ) |
---|
| 1395 | { |
---|
| 1396 | WRITE_CODE( pcVPS->getDefaultDirectDependencyType( ), pcVPS->getDirectDepTypeLenMinus2( ) + 2 , "default_direct_dependency_type" ); |
---|
| 1397 | } |
---|
| 1398 | |
---|
[964] | 1399 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 2; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1400 | { |
---|
| 1401 | for( Int j = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; j < i; j++ ) |
---|
[738] | 1402 | { |
---|
| 1403 | if (pcVPS->getDirectDependencyFlag( i, j) ) |
---|
| 1404 | { |
---|
| 1405 | if ( pcVPS->getDefaultDirectDependencyFlag( ) ) |
---|
| 1406 | { |
---|
| 1407 | assert( pcVPS->getDirectDependencyType( i, j ) == pcVPS->getDefaultDirectDependencyType( ) ); |
---|
| 1408 | } |
---|
| 1409 | else |
---|
| 1410 | { |
---|
| 1411 | assert ( pcVPS->getDirectDependencyType( i, j ) != -1 ); |
---|
| 1412 | WRITE_CODE( pcVPS->getDirectDependencyType( i, j ),pcVPS->getDirectDepTypeLenMinus2( ) + 2, "direct_dependency_type[i][j]" ); |
---|
| 1413 | } |
---|
| 1414 | } |
---|
| 1415 | } |
---|
| 1416 | } |
---|
[872] | 1417 | WRITE_UVLC( 0, "vps_non_vui_extension_length" ); |
---|
[964] | 1418 | |
---|
| 1419 | |
---|
| 1420 | |
---|
| 1421 | |
---|
[976] | 1422 | WRITE_FLAG( pcVPS->getVpsVuiPresentFlag() ? 1 : 0 , "vps_vui_present_flag" ); |
---|
[884] | 1423 | if( pcVPS->getVpsVuiPresentFlag() ) |
---|
| 1424 | { |
---|
| 1425 | m_pcBitIf->writeAlignOne(); // vps_vui_alignment_bit_equal_to_one |
---|
| 1426 | codeVPSVUI( pcVPS ); |
---|
| 1427 | } |
---|
[1124] | 1428 | else |
---|
[884] | 1429 | { |
---|
[1200] | 1430 | const TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); |
---|
[884] | 1431 | assert( pcVPSVUI ); |
---|
[1200] | 1432 | assert( !pcVPSVUI->getCrossLayerIrapAlignedFlag() ); |
---|
[884] | 1433 | } |
---|
[964] | 1434 | |
---|
[622] | 1435 | } |
---|
[884] | 1436 | |
---|
[1200] | 1437 | Void TEncCavlc::codeVideoSignalInfo( const TComVideoSignalInfo* pcVideoSignalInfo ) |
---|
[738] | 1438 | { |
---|
| 1439 | assert( pcVideoSignalInfo ); |
---|
| 1440 | WRITE_CODE( pcVideoSignalInfo->getVideoVpsFormat( ), 3, "video_vps_format" ); |
---|
| 1441 | WRITE_FLAG( pcVideoSignalInfo->getVideoFullRangeVpsFlag( ) ? 1 : 0 , "video_full_range_vps_flag" ); |
---|
| 1442 | WRITE_CODE( pcVideoSignalInfo->getColourPrimariesVps( ), 8, "colour_primaries_vps" ); |
---|
| 1443 | WRITE_CODE( pcVideoSignalInfo->getTransferCharacteristicsVps( ), 8, "transfer_characteristics_vps" ); |
---|
| 1444 | WRITE_CODE( pcVideoSignalInfo->getMatrixCoeffsVps( ), 8, "matrix_coeffs_vps" ); |
---|
| 1445 | } |
---|
[622] | 1446 | |
---|
[1200] | 1447 | Void TEncCavlc::codeDpbSize( const TComVPS* vps ) |
---|
[738] | 1448 | { |
---|
[1200] | 1449 | const TComDpbSize * dpbSize = vps->getDpbSize(); |
---|
[738] | 1450 | |
---|
| 1451 | for( Int i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
---|
| 1452 | { |
---|
[964] | 1453 | Int currLsIdx = vps->olsIdxToLsIdx( i ); |
---|
[738] | 1454 | WRITE_FLAG( dpbSize->getSubLayerFlagInfoPresentFlag( i ) ? 1 : 0 , "sub_layer_flag_info_present_flag" ); |
---|
[964] | 1455 | for( Int j = 0; j <= vps->getMaxSubLayersInLayerSetMinus1( currLsIdx ); j++ ) |
---|
[738] | 1456 | { |
---|
| 1457 | if( j > 0 && dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) ) |
---|
| 1458 | { |
---|
| 1459 | WRITE_FLAG( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) ? 1 : 0 , "sub_layer_dpb_info_present_flag" ); |
---|
| 1460 | } |
---|
| 1461 | if( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) ) |
---|
| 1462 | { |
---|
[964] | 1463 | for( Int k = 0; k < vps->getNumLayersInIdList( currLsIdx ); k++ ) |
---|
[738] | 1464 | { |
---|
[1066] | 1465 | if ( vps->getNecessaryLayerFlag( i, k ) && ( vps->getVpsBaseLayerInternalFlag() || ( vps->getLayerSetLayerIdList(vps->olsIdxToLsIdx(i),k) != 0 ) )) |
---|
| 1466 | { |
---|
| 1467 | WRITE_UVLC( dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j ), "max_vps_dec_pic_buffering_minus1" ); |
---|
| 1468 | } |
---|
| 1469 | else |
---|
| 1470 | { |
---|
| 1471 | if ( vps->getNecessaryLayerFlag( i, k ) && ( j == 0 ) && ( k == 0 ) ) |
---|
| 1472 | { |
---|
| 1473 | assert( dpbSize->getMaxVpsDecPicBufferingMinus1(i ,k, j ) == 0 ); |
---|
| 1474 | } |
---|
| 1475 | } |
---|
[738] | 1476 | } |
---|
| 1477 | WRITE_UVLC( dpbSize->getMaxVpsNumReorderPics( i, j ), "max_vps_num_reorder_pics" ); |
---|
| 1478 | WRITE_UVLC( dpbSize->getMaxVpsLatencyIncreasePlus1( i, j ), "max_vps_latency_increase_plus1" ); |
---|
| 1479 | } |
---|
| 1480 | else |
---|
| 1481 | { |
---|
| 1482 | if ( j > 0 ) |
---|
| 1483 | { |
---|
[964] | 1484 | for( Int k = 0; k < vps->getNumLayersInIdList( vps->olsIdxToLsIdx( i ) ); k++ ) |
---|
[738] | 1485 | { |
---|
[1066] | 1486 | if ( vps->getNecessaryLayerFlag(i, k ) ) |
---|
| 1487 | { |
---|
| 1488 | assert( dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j ) == dpbSize->getMaxVpsDecPicBufferingMinus1( i,k, j - 1 ) ); |
---|
| 1489 | } |
---|
[738] | 1490 | } |
---|
| 1491 | assert( dpbSize->getMaxVpsNumReorderPics ( i, j ) == dpbSize->getMaxVpsNumReorderPics ( i, j - 1 ) ); |
---|
| 1492 | assert( dpbSize->getMaxVpsLatencyIncreasePlus1( i, j ) == dpbSize->getMaxVpsLatencyIncreasePlus1( i, j - 1 ) ); |
---|
| 1493 | } |
---|
| 1494 | } |
---|
[964] | 1495 | } |
---|
| 1496 | } |
---|
[738] | 1497 | } |
---|
| 1498 | |
---|
[1200] | 1499 | Void TEncCavlc::codeRepFormat( Int i, const TComRepFormat* pcRepFormat, const TComRepFormat* pcPrevRepFormat ) |
---|
[622] | 1500 | { |
---|
| 1501 | assert( pcRepFormat ); |
---|
| 1502 | |
---|
[738] | 1503 | WRITE_CODE( pcRepFormat->getPicWidthVpsInLumaSamples( ), 16, "pic_width_vps_in_luma_samples" ); |
---|
| 1504 | WRITE_CODE( pcRepFormat->getPicHeightVpsInLumaSamples( ), 16, "pic_height_vps_in_luma_samples" ); |
---|
| 1505 | WRITE_FLAG( pcRepFormat->getChromaAndBitDepthVpsPresentFlag( ) ? 1 : 0 , "chroma_and_bit_depth_vps_present_flag" ); |
---|
| 1506 | |
---|
| 1507 | pcRepFormat->checkChromaAndBitDepthVpsPresentFlag( i ); |
---|
| 1508 | |
---|
| 1509 | if ( pcRepFormat->getChromaAndBitDepthVpsPresentFlag() ) |
---|
| 1510 | { |
---|
[1179] | 1511 | WRITE_CODE( pcRepFormat->getChromaFormatVpsIdc( ), 2, "chroma_format_vps_idc" ); |
---|
[622] | 1512 | |
---|
[1179] | 1513 | if ( pcRepFormat->getChromaFormatVpsIdc() == 3 ) |
---|
| 1514 | { |
---|
| 1515 | WRITE_FLAG( pcRepFormat->getSeparateColourPlaneVpsFlag( ) ? 1 : 0 , "separate_colour_plane_vps_flag" ); |
---|
| 1516 | } |
---|
| 1517 | WRITE_CODE( pcRepFormat->getBitDepthVpsLumaMinus8( ), 4, "bit_depth_vps_luma_minus8" ); |
---|
| 1518 | WRITE_CODE( pcRepFormat->getBitDepthVpsChromaMinus8( ), 4, "bit_depth_vps_chroma_minus8" ); |
---|
[622] | 1519 | } |
---|
[738] | 1520 | else |
---|
| 1521 | { |
---|
[1200] | 1522 | pcRepFormat->checkInferChromaAndBitDepth(pcPrevRepFormat ); |
---|
[738] | 1523 | } |
---|
[1066] | 1524 | WRITE_FLAG( pcRepFormat->getConformanceWindowVpsFlag( ) ? 1 : 0 , "conformance_window_vps_flag" ); |
---|
| 1525 | if ( pcRepFormat->getConformanceWindowVpsFlag() ) |
---|
| 1526 | { |
---|
| 1527 | WRITE_UVLC( pcRepFormat->getConfWinVpsLeftOffset( ), "conf_win_vps_left_offset" ); |
---|
| 1528 | WRITE_UVLC( pcRepFormat->getConfWinVpsRightOffset( ), "conf_win_vps_right_offset" ); |
---|
| 1529 | WRITE_UVLC( pcRepFormat->getConfWinVpsTopOffset( ), "conf_win_vps_top_offset" ); |
---|
| 1530 | WRITE_UVLC( pcRepFormat->getConfWinVpsBottomOffset( ), "conf_win_vps_bottom_offset" ); |
---|
| 1531 | } |
---|
[622] | 1532 | } |
---|
| 1533 | |
---|
[1200] | 1534 | Void TEncCavlc::codeVPSVUI( const TComVPS* pcVPS ) |
---|
[622] | 1535 | { |
---|
| 1536 | assert( pcVPS ); |
---|
| 1537 | |
---|
[1200] | 1538 | const TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); |
---|
[622] | 1539 | |
---|
| 1540 | assert( pcVPSVUI ); |
---|
| 1541 | |
---|
[964] | 1542 | |
---|
[738] | 1543 | WRITE_FLAG( pcVPSVUI->getCrossLayerPicTypeAlignedFlag( ) ? 1 : 0 , "cross_layer_pic_type_aligned_flag" ); |
---|
| 1544 | if ( !pcVPSVUI->getCrossLayerPicTypeAlignedFlag() ) |
---|
| 1545 | { |
---|
| 1546 | WRITE_FLAG( pcVPSVUI->getCrossLayerIrapAlignedFlag( ) ? 1 : 0 , "cross_layer_irap_aligned_flag" ); |
---|
| 1547 | } |
---|
[872] | 1548 | if( pcVPSVUI->getCrossLayerIrapAlignedFlag( ) ) |
---|
| 1549 | { |
---|
| 1550 | WRITE_FLAG( pcVPSVUI->getAllLayersIdrAlignedFlag( ) ? 1 : 0 , "all_layers_idr_aligned_flag" ); |
---|
| 1551 | } |
---|
[622] | 1552 | WRITE_FLAG( pcVPSVUI->getBitRatePresentVpsFlag( ) ? 1 : 0 , "bit_rate_present_vps_flag" ); |
---|
| 1553 | WRITE_FLAG( pcVPSVUI->getPicRatePresentVpsFlag( ) ? 1 : 0 , "pic_rate_present_vps_flag" ); |
---|
| 1554 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) || pcVPSVUI->getPicRatePresentVpsFlag( ) ) |
---|
| 1555 | { |
---|
[1066] | 1556 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i < pcVPS->getNumLayerSets(); i++ ) |
---|
[622] | 1557 | { |
---|
[964] | 1558 | for( Int j = 0; j <= pcVPS->getMaxSubLayersInLayerSetMinus1( i ); j++ ) |
---|
[622] | 1559 | { |
---|
| 1560 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) ) |
---|
| 1561 | { |
---|
| 1562 | WRITE_FLAG( pcVPSVUI->getBitRatePresentFlag( i, j ) ? 1 : 0 , "bit_rate_present_flag" ); |
---|
| 1563 | } |
---|
| 1564 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) ) |
---|
| 1565 | { |
---|
| 1566 | WRITE_FLAG( pcVPSVUI->getPicRatePresentFlag( i, j ) ? 1 : 0 , "pic_rate_present_flag" ); |
---|
| 1567 | } |
---|
| 1568 | if( pcVPSVUI->getBitRatePresentFlag( i, j ) ) |
---|
| 1569 | { |
---|
| 1570 | WRITE_CODE( pcVPSVUI->getAvgBitRate( i, j ), 16, "avg_bit_rate" ); |
---|
| 1571 | WRITE_CODE( pcVPSVUI->getMaxBitRate( i, j ), 16, "max_bit_rate" ); |
---|
| 1572 | } |
---|
| 1573 | if( pcVPSVUI->getPicRatePresentFlag( i, j ) ) |
---|
| 1574 | { |
---|
| 1575 | WRITE_CODE( pcVPSVUI->getConstantPicRateIdc( i, j ), 2, "constant_pic_rate_idc" ); |
---|
| 1576 | WRITE_CODE( pcVPSVUI->getAvgPicRate( i, j ), 16, "avg_pic_rate" ); |
---|
| 1577 | } |
---|
| 1578 | } |
---|
| 1579 | } |
---|
| 1580 | } |
---|
| 1581 | |
---|
[872] | 1582 | WRITE_FLAG( pcVPSVUI->getVideoSignalInfoIdxPresentFlag( ) ? 1 : 0 , "video_signal_info_idx_present_flag" ); |
---|
| 1583 | if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() ) |
---|
| 1584 | { |
---|
| 1585 | WRITE_CODE( pcVPSVUI->getVpsNumVideoSignalInfoMinus1( ), 4, "vps_num_video_signal_info_minus1" ); |
---|
| 1586 | } |
---|
| 1587 | else |
---|
| 1588 | { |
---|
[1066] | 1589 | assert( pcVPSVUI->getVpsNumVideoSignalInfoMinus1() == pcVPS->getMaxLayersMinus1() - ( pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1) ); |
---|
[872] | 1590 | } |
---|
| 1591 | |
---|
| 1592 | for( Int i = 0; i <= pcVPSVUI->getVpsNumVideoSignalInfoMinus1(); i++ ) |
---|
| 1593 | { |
---|
| 1594 | assert( pcVPSVUI->getVideoSignalInfo( i ) != NULL ); |
---|
[1200] | 1595 | const TComVideoSignalInfo* curVideoSignalInfo = pcVPSVUI->getVideoSignalInfo( i ); |
---|
[872] | 1596 | codeVideoSignalInfo( curVideoSignalInfo ); |
---|
| 1597 | |
---|
| 1598 | } |
---|
| 1599 | |
---|
| 1600 | if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() && pcVPSVUI->getVpsNumVideoSignalInfoMinus1() > 0 ) |
---|
| 1601 | { |
---|
[1066] | 1602 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1603 | { |
---|
| 1604 | WRITE_CODE( pcVPSVUI->getVpsVideoSignalInfoIdx( i ), 4, "vps_video_signal_info_idx" ); |
---|
| 1605 | } |
---|
[872] | 1606 | } |
---|
[738] | 1607 | WRITE_FLAG( pcVPSVUI->getTilesNotInUseFlag( ) ? 1 : 0 , "tiles_not_in_use_flag" ); |
---|
| 1608 | if( !pcVPSVUI->getTilesNotInUseFlag() ) |
---|
| 1609 | { |
---|
[964] | 1610 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
[738] | 1611 | { |
---|
| 1612 | WRITE_FLAG( pcVPSVUI->getTilesInUseFlag( i ) ? 1 : 0 , "tiles_in_use_flag[i]" ); |
---|
| 1613 | if( pcVPSVUI->getTilesInUseFlag( i ) ) |
---|
| 1614 | { |
---|
| 1615 | WRITE_FLAG( pcVPSVUI->getLoopFilterNotAcrossTilesFlag( i ) ? 1 : 0, "loop_filter_not_across_tiles_flag[i]" ); |
---|
| 1616 | } |
---|
| 1617 | } |
---|
[964] | 1618 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 2; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
[738] | 1619 | { |
---|
| 1620 | for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ) ; j++ ) |
---|
| 1621 | { |
---|
[1066] | 1622 | Int layerIdx = pcVPS->getLayerIdInVps(pcVPS->getIdRefLayer(pcVPS->getLayerIdInNuh( i ) , j )); |
---|
[738] | 1623 | if( pcVPSVUI->getTilesInUseFlag( i ) && pcVPSVUI->getTilesInUseFlag( layerIdx ) ) |
---|
| 1624 | { |
---|
| 1625 | WRITE_FLAG( pcVPSVUI->getTileBoundariesAlignedFlag( i, j ) ? 1 : 0 , "tile_boundaries_aligned_flag[i][j]" ); |
---|
| 1626 | } |
---|
| 1627 | } |
---|
| 1628 | } |
---|
| 1629 | } |
---|
| 1630 | |
---|
| 1631 | WRITE_FLAG( pcVPSVUI->getWppNotInUseFlag( ) ? 1 : 0 , "wpp_not_in_use_flag" ); |
---|
| 1632 | |
---|
| 1633 | if( !pcVPSVUI->getWppNotInUseFlag( ) ) |
---|
| 1634 | { |
---|
| 1635 | for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1636 | { |
---|
| 1637 | WRITE_FLAG( pcVPSVUI->getWppInUseFlag( i ) ? 1 : 0 , "wpp_in_use_flag[i]" ); |
---|
| 1638 | } |
---|
| 1639 | } |
---|
[1066] | 1640 | WRITE_FLAG( pcVPSVUI->getSingleLayerForNonIrapFlag( ) ? 1 : 0 , "single_layer_for_non_irap_flag" ); |
---|
| 1641 | WRITE_FLAG( pcVPSVUI->getHigherLayerIrapSkipFlag( ) ? 1 : 0 , "higher_layer_irap_skip_flag" ); |
---|
[622] | 1642 | WRITE_FLAG( pcVPSVUI->getIlpRestrictedRefLayersFlag( ) ? 1 : 0 , "ilp_restricted_ref_layers_flag" ); |
---|
| 1643 | |
---|
| 1644 | if( pcVPSVUI->getIlpRestrictedRefLayersFlag( ) ) |
---|
| 1645 | { |
---|
| 1646 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1647 | { |
---|
| 1648 | for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ); j++ ) |
---|
| 1649 | { |
---|
[1066] | 1650 | if( pcVPS->getVpsBaseLayerInternalFlag() || pcVPS->getIdRefLayer( pcVPS->getLayerIdInNuh( i ), j ) > 0 ) |
---|
[964] | 1651 | { |
---|
[976] | 1652 | WRITE_UVLC( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ), "min_spatial_segment_offset_plus1" ); |
---|
| 1653 | if( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ) > 0 ) |
---|
[622] | 1654 | { |
---|
[976] | 1655 | WRITE_FLAG( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) ? 1 : 0 , "ctu_based_offset_enabled_flag" ); |
---|
| 1656 | if( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) ) |
---|
| 1657 | { |
---|
| 1658 | WRITE_UVLC( pcVPSVUI->getMinHorizontalCtuOffsetPlus1( i, j ), "min_horizontal_ctu_offset_plus1" ); |
---|
| 1659 | } |
---|
[622] | 1660 | } |
---|
| 1661 | } |
---|
| 1662 | } |
---|
| 1663 | } |
---|
| 1664 | } |
---|
[872] | 1665 | |
---|
[738] | 1666 | |
---|
| 1667 | WRITE_FLAG( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) ? 1 : 0 , "vps_vui_bsp_hrd_present_flag" ); |
---|
| 1668 | if ( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) ) |
---|
| 1669 | { |
---|
| 1670 | codeVpsVuiBspHrdParameters( pcVPS ); |
---|
| 1671 | } |
---|
[872] | 1672 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1673 | { |
---|
| 1674 | if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i )) == 0 ) |
---|
| 1675 | { |
---|
| 1676 | WRITE_FLAG( pcVPSVUI->getBaseLayerParameterSetCompatibilityFlag( i ) ? 1 : 0 , "base_layer_parameter_set_compatibility_flag" ); |
---|
| 1677 | } |
---|
[884] | 1678 | } |
---|
[738] | 1679 | } |
---|
[872] | 1680 | |
---|
[1200] | 1681 | Void TEncCavlc::codeVpsVuiBspHrdParameters( const TComVPS* pcVPS ) |
---|
[738] | 1682 | { |
---|
| 1683 | assert( pcVPS ); |
---|
[622] | 1684 | |
---|
[1200] | 1685 | const TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); |
---|
[738] | 1686 | |
---|
| 1687 | assert( pcVPSVUI ); |
---|
| 1688 | |
---|
[1200] | 1689 | const TComVpsVuiBspHrdParameters* vpsVuiBspHrdP = pcVPSVUI->getVpsVuiBspHrdParameters(); |
---|
[738] | 1690 | |
---|
| 1691 | assert ( vpsVuiBspHrdP ); |
---|
[1066] | 1692 | |
---|
| 1693 | WRITE_UVLC( vpsVuiBspHrdP->getVpsNumAddHrdParams( ), "vps_num_add_hrd_params" ); |
---|
[738] | 1694 | |
---|
[1066] | 1695 | for( Int i = pcVPS->getNumHrdParameters(); i < pcVPS->getNumHrdParameters() + vpsVuiBspHrdP->getVpsNumAddHrdParams(); i++ ) |
---|
| 1696 | { |
---|
| 1697 | if( i > 0 ) |
---|
| 1698 | { |
---|
| 1699 | WRITE_FLAG( vpsVuiBspHrdP->getCprmsAddPresentFlag( i ) ? 1 : 0 , "cprms_add_present_flag" ); |
---|
| 1700 | } |
---|
| 1701 | WRITE_UVLC( vpsVuiBspHrdP->getNumSubLayerHrdMinus1( i ), "num_sub_layer_hrd_minus1" ); |
---|
[1200] | 1702 | const TComHRD* hrdParameters = vpsVuiBspHrdP->getHrdParametermeters( i ); |
---|
[1066] | 1703 | codeHrdParameters( hrdParameters, vpsVuiBspHrdP->getCprmsAddPresentFlag( i ), vpsVuiBspHrdP->getNumSubLayerHrdMinus1( i ) ); |
---|
| 1704 | } |
---|
| 1705 | |
---|
| 1706 | for( Int h = 1; h < pcVPS->getNumOutputLayerSets(); h++ ) |
---|
| 1707 | { |
---|
| 1708 | WRITE_UVLC( vpsVuiBspHrdP->getNumSignalledPartitioningSchemes( h ), "num_signalled_partitioning_schemes" ); |
---|
| 1709 | |
---|
| 1710 | for( Int j = 1; j < vpsVuiBspHrdP->getNumSignalledPartitioningSchemes( h ) + 1; j++ ) |
---|
| 1711 | { |
---|
| 1712 | WRITE_UVLC( vpsVuiBspHrdP->getNumPartitionsInSchemeMinus1( h, j ), "num_partitions_in_scheme_minus1" ); |
---|
| 1713 | for( Int k = 0; k <= vpsVuiBspHrdP->getNumPartitionsInSchemeMinus1( h, j ); k++ ) |
---|
| 1714 | { |
---|
| 1715 | for( Int r = 0; r < pcVPS->getNumLayersInIdList(pcVPS->olsIdxToLsIdx( h ) ) ; r++ ) |
---|
| 1716 | { |
---|
| 1717 | WRITE_FLAG( vpsVuiBspHrdP->getLayerIncludedInPartitionFlag( h, j, k, r ) ? 1 : 0 , "layer_included_in_partition_flag" ); |
---|
| 1718 | } |
---|
| 1719 | } |
---|
| 1720 | } |
---|
| 1721 | for( Int i = 0; i < vpsVuiBspHrdP->getNumSignalledPartitioningSchemes( h ) + 1; i++ ) |
---|
| 1722 | { |
---|
| 1723 | for( Int t = 0; t <= pcVPS->getMaxSubLayersInLayerSetMinus1( pcVPS->olsIdxToLsIdx( h ) ); t++ ) |
---|
| 1724 | { |
---|
| 1725 | WRITE_UVLC( vpsVuiBspHrdP->getNumBspSchedulesMinus1( h, i, t ), "num_bsp_schedules_minus1" ); |
---|
| 1726 | for( Int j = 0; j <= vpsVuiBspHrdP->getNumBspSchedulesMinus1( h, i, t ); j++ ) |
---|
| 1727 | { |
---|
| 1728 | for( Int k = 0; k <= vpsVuiBspHrdP->getNumPartitionsInSchemeMinus1( h, j ); k++ ) |
---|
| 1729 | { |
---|
| 1730 | WRITE_CODE( vpsVuiBspHrdP->getBspHrdIdx( h, i, t, j, k ), vpsVuiBspHrdP->getBspHrdIdxLen( pcVPS ), "bsp_hrd_idx" ); |
---|
| 1731 | WRITE_UVLC( vpsVuiBspHrdP->getBspSchedIdx( h, i, t, j, k ), "bsp_sched_idx" ); |
---|
| 1732 | } |
---|
| 1733 | } |
---|
| 1734 | } |
---|
| 1735 | } |
---|
| 1736 | } |
---|
[738] | 1737 | } |
---|
| 1738 | #endif |
---|
| 1739 | |
---|
[1200] | 1740 | #if NH_3D |
---|
| 1741 | Void TEncCavlc::codeVPS3dExtension( const TComVPS* pcVPS ) |
---|
[622] | 1742 | { |
---|
[1179] | 1743 | WRITE_UVLC( pcVPS->getCpPrecision( ), "cp_precision" ); |
---|
| 1744 | for (Int n = 1; n < pcVPS->getNumViews(); n++) |
---|
| 1745 | { |
---|
| 1746 | Int i = pcVPS->getViewOIdxList( n ); |
---|
| 1747 | Int iInVps = pcVPS->getVoiInVps( i ); |
---|
| 1748 | WRITE_CODE( pcVPS->getNumCp( iInVps ), 6, "num_cp" ); |
---|
| 1749 | |
---|
| 1750 | if( pcVPS->getNumCp( iInVps ) > 0 ) |
---|
| 1751 | { |
---|
| 1752 | WRITE_FLAG( pcVPS->getCpInSliceSegmentHeaderFlag( iInVps ) ? 1 : 0 , "cp_in_slice_segment_header_flag" ); |
---|
| 1753 | for( Int m = 0; m < pcVPS->getNumCp( iInVps ); m++ ) |
---|
| 1754 | { |
---|
| 1755 | WRITE_UVLC( pcVPS->getCpRefVoi( iInVps, m ), "cp_ref_voi" ); |
---|
| 1756 | if( !pcVPS->getCpInSliceSegmentHeaderFlag( iInVps ) ) |
---|
| 1757 | { |
---|
| 1758 | Int j = pcVPS->getCpRefVoi( iInVps, m ); |
---|
| 1759 | Int jInVps = pcVPS->getVoiInVps( j ); |
---|
| 1760 | WRITE_SVLC( pcVPS->getVpsCpScale ( iInVps, jInVps ), "vps_cp_scale" ); |
---|
| 1761 | WRITE_SVLC( pcVPS->getVpsCpOff ( iInVps, jInVps ), "vps_cp_off" ); |
---|
| 1762 | WRITE_SVLC( pcVPS->getVpsCpInvScale( iInVps, jInVps ) + pcVPS->getVpsCpScale( iInVps, jInVps ), "vps_cp_inv_scale_plus_scale" ); |
---|
| 1763 | WRITE_SVLC( pcVPS->getVpsCpInvOff ( iInVps, jInVps ) + pcVPS->getVpsCpOff ( iInVps, jInVps ), "vps_cp_inv_off_plus_off" ); |
---|
| 1764 | } |
---|
| 1765 | } |
---|
| 1766 | } |
---|
| 1767 | } |
---|
[622] | 1768 | } |
---|
| 1769 | #endif |
---|
| 1770 | |
---|
[1200] | 1771 | |
---|
[56] | 1772 | Void TEncCavlc::codeSliceHeader ( TComSlice* pcSlice ) |
---|
[2] | 1773 | { |
---|
[1200] | 1774 | #if NH_MV |
---|
| 1775 | const TComVPS* vps = pcSlice->getVPS(); |
---|
[608] | 1776 | #endif |
---|
[1200] | 1777 | |
---|
| 1778 | #if ENC_DEC_TRACE |
---|
| 1779 | #if NH_MV |
---|
| 1780 | tracePSHeader( "Slice", pcSlice->getLayerId() ); |
---|
| 1781 | #else |
---|
| 1782 | xTraceSliceHeader (); |
---|
[2] | 1783 | #endif |
---|
[1200] | 1784 | #endif |
---|
[2] | 1785 | |
---|
[1200] | 1786 | const ChromaFormat format = pcSlice->getSPS()->getChromaFormatIdc(); |
---|
| 1787 | const UInt numberValidComponents = getNumberValidComponents(format); |
---|
| 1788 | const Bool chromaEnabled = isChromaEnabled(format); |
---|
| 1789 | |
---|
[56] | 1790 | //calculate number of bits required for slice address |
---|
[1200] | 1791 | Int maxSliceSegmentAddress = pcSlice->getPic()->getNumberOfCtusInFrame(); |
---|
[608] | 1792 | Int bitsSliceSegmentAddress = 0; |
---|
[1200] | 1793 | while(maxSliceSegmentAddress>(1<<bitsSliceSegmentAddress)) |
---|
[2] | 1794 | { |
---|
[608] | 1795 | bitsSliceSegmentAddress++; |
---|
[2] | 1796 | } |
---|
[1200] | 1797 | const Int ctuTsAddress = pcSlice->getSliceSegmentCurStartCtuTsAddr(); |
---|
| 1798 | |
---|
[56] | 1799 | //write slice address |
---|
[1200] | 1800 | const Int sliceSegmentRsAddress = pcSlice->getPic()->getPicSym()->getCtuTsToRsAddrMap(ctuTsAddress); |
---|
[189] | 1801 | |
---|
[1200] | 1802 | WRITE_FLAG( sliceSegmentRsAddress==0, "first_slice_segment_in_pic_flag" ); |
---|
[608] | 1803 | if ( pcSlice->getRapPicFlag() ) |
---|
[189] | 1804 | { |
---|
[964] | 1805 | WRITE_FLAG( pcSlice->getNoOutputPriorPicsFlag() ? 1 : 0, "no_output_of_prior_pics_flag" ); |
---|
[608] | 1806 | } |
---|
[773] | 1807 | #if PPS_FIX_DEPTH |
---|
| 1808 | if( pcSlice->getIsDepth() ) |
---|
| 1809 | { |
---|
| 1810 | WRITE_UVLC( 1, "slice_pic_parameter_set_id" ); |
---|
| 1811 | } |
---|
| 1812 | else |
---|
| 1813 | #endif |
---|
[1200] | 1814 | |
---|
[608] | 1815 | WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "slice_pic_parameter_set_id" ); |
---|
[1200] | 1816 | if ( pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag() && (sliceSegmentRsAddress!=0) ) |
---|
[608] | 1817 | { |
---|
| 1818 | WRITE_FLAG( pcSlice->getDependentSliceSegmentFlag() ? 1 : 0, "dependent_slice_segment_flag" ); |
---|
| 1819 | } |
---|
[1200] | 1820 | if(sliceSegmentRsAddress>0) |
---|
[608] | 1821 | { |
---|
[1200] | 1822 | WRITE_CODE( sliceSegmentRsAddress, bitsSliceSegmentAddress, "slice_segment_address" ); |
---|
[608] | 1823 | } |
---|
| 1824 | if ( !pcSlice->getDependentSliceSegmentFlag() ) |
---|
| 1825 | { |
---|
[1200] | 1826 | |
---|
| 1827 | #if NH_MV |
---|
[622] | 1828 | Int esb = 0; //Don't use i, otherwise will shadow something below |
---|
| 1829 | |
---|
| 1830 | if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb ) |
---|
| 1831 | { |
---|
| 1832 | esb++; |
---|
| 1833 | WRITE_FLAG( pcSlice->getDiscardableFlag( ) ? 1 : 0 , "discardable_flag" ); |
---|
[1066] | 1834 | if (pcSlice->getDiscardableFlag( )) |
---|
| 1835 | { |
---|
| 1836 | assert(pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R && |
---|
| 1837 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R && |
---|
| 1838 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R && |
---|
| 1839 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R && |
---|
| 1840 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R); |
---|
| 1841 | } |
---|
[622] | 1842 | } |
---|
| 1843 | |
---|
[738] | 1844 | if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb ) |
---|
| 1845 | { |
---|
| 1846 | esb++; |
---|
| 1847 | WRITE_FLAG( pcSlice->getCrossLayerBlaFlag( ) ? 1 : 0 , "cross_layer_bla_flag" ); |
---|
| 1848 | } |
---|
| 1849 | pcSlice->checkCrossLayerBlaFlag( ); |
---|
| 1850 | |
---|
[622] | 1851 | for (; esb < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); esb++) |
---|
| 1852 | #else |
---|
[608] | 1853 | for (Int i = 0; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
| 1854 | #endif |
---|
[443] | 1855 | { |
---|
[1200] | 1856 | WRITE_FLAG(0, "slice_reserved_flag[]"); |
---|
[443] | 1857 | } |
---|
[189] | 1858 | |
---|
[1200] | 1859 | |
---|
| 1860 | |
---|
[608] | 1861 | WRITE_UVLC( pcSlice->getSliceType(), "slice_type" ); |
---|
[2] | 1862 | |
---|
[56] | 1863 | if( pcSlice->getPPS()->getOutputFlagPresentFlag() ) |
---|
[2] | 1864 | { |
---|
[56] | 1865 | WRITE_FLAG( pcSlice->getPicOutputFlag() ? 1 : 0, "pic_output_flag" ); |
---|
[2] | 1866 | } |
---|
[608] | 1867 | |
---|
[1200] | 1868 | #if NH_MV |
---|
[738] | 1869 | if ( (pcSlice->getLayerId() > 0 && !vps->getPocLsbNotPresentFlag( pcSlice->getLayerIdInVps())) || !pcSlice->getIdrPicFlag() ) |
---|
| 1870 | { |
---|
| 1871 | Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); |
---|
| 1872 | WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "slice_pic_order_cnt_lsb"); |
---|
[964] | 1873 | pcSlice->setSlicePicOrderCntLsb( picOrderCntLSB ); |
---|
[738] | 1874 | } |
---|
[964] | 1875 | |
---|
[738] | 1876 | #endif |
---|
[1200] | 1877 | |
---|
[608] | 1878 | if( !pcSlice->getIdrPicFlag() ) |
---|
[2] | 1879 | { |
---|
[1200] | 1880 | #if !NH_MV |
---|
[655] | 1881 | Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); |
---|
[1200] | 1882 | WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "slice_pic_order_cnt_lsb"); |
---|
[738] | 1883 | #endif |
---|
[1200] | 1884 | const TComReferencePictureSet* rps = pcSlice->getRPS(); |
---|
| 1885 | |
---|
[608] | 1886 | // check for bitstream restriction stating that: |
---|
| 1887 | // If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
| 1888 | // Ideally this process should not be repeated for each slice in a picture |
---|
| 1889 | if (pcSlice->isIRAP()) |
---|
| 1890 | { |
---|
[1200] | 1891 | for (Int picIdx = 0; picIdx < rps->getNumberOfPictures(); picIdx++) |
---|
| 1892 | { |
---|
[608] | 1893 | assert (!rps->getUsed(picIdx)); |
---|
| 1894 | } |
---|
[1200] | 1895 | } |
---|
[608] | 1896 | |
---|
| 1897 | if(pcSlice->getRPSidx() < 0) |
---|
[77] | 1898 | { |
---|
[608] | 1899 | WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag"); |
---|
[1200] | 1900 | codeShortTermRefPicSet( rps, true, pcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()); |
---|
[608] | 1901 | } |
---|
| 1902 | else |
---|
| 1903 | { |
---|
| 1904 | WRITE_FLAG( 1, "short_term_ref_pic_set_sps_flag"); |
---|
| 1905 | Int numBits = 0; |
---|
| 1906 | while ((1 << numBits) < pcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
---|
[77] | 1907 | { |
---|
[608] | 1908 | numBits++; |
---|
[77] | 1909 | } |
---|
[608] | 1910 | if (numBits > 0) |
---|
[77] | 1911 | { |
---|
[1200] | 1912 | WRITE_CODE( pcSlice->getRPSidx(), numBits, "short_term_ref_pic_set_idx" ); |
---|
[77] | 1913 | } |
---|
[608] | 1914 | } |
---|
| 1915 | if(pcSlice->getSPS()->getLongTermRefsPresent()) |
---|
| 1916 | { |
---|
| 1917 | Int numLtrpInSH = rps->getNumberOfLongtermPictures(); |
---|
| 1918 | Int ltrpInSPS[MAX_NUM_REF_PICS]; |
---|
| 1919 | Int numLtrpInSPS = 0; |
---|
| 1920 | UInt ltrpIndex; |
---|
| 1921 | Int counter = 0; |
---|
[1200] | 1922 | // WARNING: The following code only works only if a matching long-term RPS is |
---|
| 1923 | // found in the SPS for ALL long-term pictures |
---|
| 1924 | // The problem is that the SPS coded long-term pictures are moved to the |
---|
| 1925 | // beginning of the list which causes a mismatch when no reference picture |
---|
| 1926 | // list reordering is used |
---|
| 1927 | // NB: Long-term coding is currently not supported in general by the HM encoder |
---|
| 1928 | for(Int k = rps->getNumberOfPictures()-1; k > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; k--) |
---|
[77] | 1929 | { |
---|
[1200] | 1930 | if (findMatchingLTRP(pcSlice, <rpIndex, rps->getPOC(k), rps->getUsed(k))) |
---|
[77] | 1931 | { |
---|
[608] | 1932 | ltrpInSPS[numLtrpInSPS] = ltrpIndex; |
---|
| 1933 | numLtrpInSPS++; |
---|
[77] | 1934 | } |
---|
[608] | 1935 | else |
---|
| 1936 | { |
---|
| 1937 | counter++; |
---|
| 1938 | } |
---|
[77] | 1939 | } |
---|
[608] | 1940 | numLtrpInSH -= numLtrpInSPS; |
---|
[1200] | 1941 | // check that either all long-term pictures are coded in SPS or in slice header (no mixing) |
---|
| 1942 | assert (numLtrpInSH==0 || numLtrpInSPS==0); |
---|
[608] | 1943 | |
---|
| 1944 | Int bitsForLtrpInSPS = 0; |
---|
| 1945 | while (pcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
[56] | 1946 | { |
---|
[608] | 1947 | bitsForLtrpInSPS++; |
---|
[56] | 1948 | } |
---|
[1200] | 1949 | if (pcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
---|
[2] | 1950 | { |
---|
[608] | 1951 | WRITE_UVLC( numLtrpInSPS, "num_long_term_sps"); |
---|
[2] | 1952 | } |
---|
[608] | 1953 | WRITE_UVLC( numLtrpInSH, "num_long_term_pics"); |
---|
| 1954 | // Note that the LSBs of the LT ref. pic. POCs must be sorted before. |
---|
| 1955 | // Not sorted here because LT ref indices will be used in setRefPicList() |
---|
| 1956 | Int prevDeltaMSB = 0, prevLSB = 0; |
---|
| 1957 | Int offset = rps->getNumberOfNegativePictures() + rps->getNumberOfPositivePictures(); |
---|
[1200] | 1958 | counter = 0; |
---|
| 1959 | // Warning: If some pictures are moved to ltrpInSPS, i is referring to a wrong index |
---|
| 1960 | // (mapping would be required) |
---|
| 1961 | for(Int i=rps->getNumberOfPictures()-1 ; i > offset-1; i--, counter++) |
---|
[2] | 1962 | { |
---|
[608] | 1963 | if (counter < numLtrpInSPS) |
---|
[56] | 1964 | { |
---|
[608] | 1965 | if (bitsForLtrpInSPS > 0) |
---|
[56] | 1966 | { |
---|
[1200] | 1967 | WRITE_CODE( ltrpInSPS[counter], bitsForLtrpInSPS, "lt_idx_sps[i]"); |
---|
[56] | 1968 | } |
---|
[608] | 1969 | } |
---|
[1200] | 1970 | else |
---|
[608] | 1971 | { |
---|
| 1972 | WRITE_CODE( rps->getPocLSBLT(i), pcSlice->getSPS()->getBitsForPOC(), "poc_lsb_lt"); |
---|
[1200] | 1973 | WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag"); |
---|
[608] | 1974 | } |
---|
| 1975 | WRITE_FLAG( rps->getDeltaPocMSBPresentFlag(i), "delta_poc_msb_present_flag"); |
---|
| 1976 | |
---|
| 1977 | if(rps->getDeltaPocMSBPresentFlag(i)) |
---|
| 1978 | { |
---|
| 1979 | Bool deltaFlag = false; |
---|
| 1980 | // First LTRP from SPS || First LTRP from SH || curr LSB != prev LSB |
---|
| 1981 | if( (i == rps->getNumberOfPictures()-1) || (i == rps->getNumberOfPictures()-1-numLtrpInSPS) || (rps->getPocLSBLT(i) != prevLSB) ) |
---|
[56] | 1982 | { |
---|
[608] | 1983 | deltaFlag = true; |
---|
[56] | 1984 | } |
---|
[608] | 1985 | if(deltaFlag) |
---|
[56] | 1986 | { |
---|
[608] | 1987 | WRITE_UVLC( rps->getDeltaPocMSBCycleLT(i), "delta_poc_msb_cycle_lt[i]" ); |
---|
[56] | 1988 | } |
---|
| 1989 | else |
---|
[1200] | 1990 | { |
---|
[608] | 1991 | Int differenceInDeltaMSB = rps->getDeltaPocMSBCycleLT(i) - prevDeltaMSB; |
---|
| 1992 | assert(differenceInDeltaMSB >= 0); |
---|
| 1993 | WRITE_UVLC( differenceInDeltaMSB, "delta_poc_msb_cycle_lt[i]" ); |
---|
[56] | 1994 | } |
---|
[608] | 1995 | prevLSB = rps->getPocLSBLT(i); |
---|
| 1996 | prevDeltaMSB = rps->getDeltaPocMSBCycleLT(i); |
---|
[56] | 1997 | } |
---|
[2] | 1998 | } |
---|
| 1999 | } |
---|
[608] | 2000 | if (pcSlice->getSPS()->getTMVPFlagsPresent()) |
---|
| 2001 | { |
---|
[1200] | 2002 | #if NH_MV |
---|
[1066] | 2003 | WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enabled_flag" ); |
---|
| 2004 | #else |
---|
[1200] | 2005 | WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enabled_flag" ); |
---|
[1066] | 2006 | #endif |
---|
[608] | 2007 | } |
---|
[2] | 2008 | } |
---|
[1200] | 2009 | #if NH_MV |
---|
[738] | 2010 | Bool interLayerPredLayerIdcPresentFlag = false; |
---|
[622] | 2011 | Int layerId = pcSlice->getLayerId(); |
---|
[1200] | 2012 | #if NH_3D |
---|
[1124] | 2013 | if( pcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumRefListLayers( layerId ) > 0 ) |
---|
| 2014 | #else |
---|
[622] | 2015 | if( pcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 ) |
---|
[1124] | 2016 | #endif |
---|
[622] | 2017 | { |
---|
| 2018 | WRITE_FLAG( pcSlice->getInterLayerPredEnabledFlag( ) ? 1 : 0 , "inter_layer_pred_enabled_flag" ); |
---|
[1200] | 2019 | #if NH_3D |
---|
[1124] | 2020 | if( pcSlice->getInterLayerPredEnabledFlag() && vps->getNumRefListLayers( layerId ) > 1 ) |
---|
| 2021 | #else |
---|
[622] | 2022 | if( pcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerId ) > 1 ) |
---|
[1124] | 2023 | #endif |
---|
[622] | 2024 | { |
---|
| 2025 | if( !vps->getMaxOneActiveRefLayerFlag()) |
---|
| 2026 | { |
---|
| 2027 | WRITE_CODE( pcSlice->getNumInterLayerRefPicsMinus1( ), pcSlice->getNumInterLayerRefPicsMinus1Len( ), "num_inter_layer_ref_pics_minus1" ); |
---|
| 2028 | } |
---|
[1200] | 2029 | #if NH_3D |
---|
[1124] | 2030 | if ( pcSlice->getNumActiveRefLayerPics() != vps->getNumRefListLayers( layerId ) ) |
---|
| 2031 | #else |
---|
[622] | 2032 | if ( pcSlice->getNumActiveRefLayerPics() != vps->getNumDirectRefLayers( layerId ) ) |
---|
[1124] | 2033 | #endif |
---|
[622] | 2034 | { |
---|
[738] | 2035 | interLayerPredLayerIdcPresentFlag = true; |
---|
[622] | 2036 | for( Int idx = 0; idx < pcSlice->getNumActiveRefLayerPics(); idx++ ) |
---|
| 2037 | { |
---|
| 2038 | WRITE_CODE( pcSlice->getInterLayerPredLayerIdc( idx ), pcSlice->getInterLayerPredLayerIdcLen( ), "inter_layer_pred_layer_idc" ); |
---|
| 2039 | } |
---|
| 2040 | } |
---|
| 2041 | } |
---|
| 2042 | } |
---|
[738] | 2043 | if ( !interLayerPredLayerIdcPresentFlag ) |
---|
| 2044 | { |
---|
| 2045 | for( Int i = 0; i < pcSlice->getNumActiveRefLayerPics(); i++ ) |
---|
| 2046 | { |
---|
| 2047 | assert( pcSlice->getInterLayerPredLayerIdc( i ) == pcSlice->getRefLayerPicIdc( i ) ); |
---|
| 2048 | } |
---|
| 2049 | } |
---|
[608] | 2050 | #endif |
---|
[1179] | 2051 | |
---|
[1200] | 2052 | #if NH_3D |
---|
[1179] | 2053 | if( getEncTop()->decProcAnnexI() ) |
---|
| 2054 | { |
---|
| 2055 | if ( pcSlice->getInCmpPredAvailFlag() ) |
---|
| 2056 | { |
---|
| 2057 | WRITE_FLAG( pcSlice->getInCompPredFlag(), "in_comp_pred_flag" ); |
---|
| 2058 | } |
---|
| 2059 | } |
---|
| 2060 | #endif |
---|
[1200] | 2061 | |
---|
[608] | 2062 | if(pcSlice->getSPS()->getUseSAO()) |
---|
| 2063 | { |
---|
[1200] | 2064 | WRITE_FLAG( pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA), "slice_sao_luma_flag" ); |
---|
| 2065 | if (chromaEnabled) |
---|
| 2066 | { |
---|
| 2067 | WRITE_FLAG( pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA), "slice_sao_chroma_flag" ); |
---|
| 2068 | } |
---|
[2] | 2069 | } |
---|
[56] | 2070 | |
---|
[608] | 2071 | //check if numrefidxes match the defaults. If not, override |
---|
| 2072 | |
---|
[56] | 2073 | if (!pcSlice->isIntra()) |
---|
| 2074 | { |
---|
[608] | 2075 | Bool overrideFlag = (pcSlice->getNumRefIdx( REF_PIC_LIST_0 )!=pcSlice->getPPS()->getNumRefIdxL0DefaultActive()||(pcSlice->isInterB()&&pcSlice->getNumRefIdx( REF_PIC_LIST_1 )!=pcSlice->getPPS()->getNumRefIdxL1DefaultActive())); |
---|
[773] | 2076 | #if PPS_FIX_DEPTH |
---|
| 2077 | overrideFlag |= (pcSlice->getIsDepth() && !pcSlice->getViewIndex()); |
---|
| 2078 | #endif |
---|
[608] | 2079 | WRITE_FLAG( overrideFlag ? 1 : 0, "num_ref_idx_active_override_flag"); |
---|
[1200] | 2080 | if (overrideFlag) |
---|
[608] | 2081 | { |
---|
| 2082 | WRITE_UVLC( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - 1, "num_ref_idx_l0_active_minus1" ); |
---|
| 2083 | if (pcSlice->isInterB()) |
---|
| 2084 | { |
---|
| 2085 | WRITE_UVLC( pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - 1, "num_ref_idx_l1_active_minus1" ); |
---|
| 2086 | } |
---|
| 2087 | else |
---|
| 2088 | { |
---|
| 2089 | pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
| 2090 | } |
---|
| 2091 | } |
---|
[56] | 2092 | } |
---|
[2] | 2093 | else |
---|
| 2094 | { |
---|
[56] | 2095 | pcSlice->setNumRefIdx(REF_PIC_LIST_0, 0); |
---|
| 2096 | pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
[2] | 2097 | } |
---|
[773] | 2098 | #if PPS_FIX_DEPTH |
---|
| 2099 | if( (pcSlice->getPPS()->getListsModificationPresentFlag() || (pcSlice->getIsDepth() && !pcSlice->getViewIndex())) && pcSlice->getNumRpsCurrTempList() > 1) |
---|
| 2100 | #else |
---|
[608] | 2101 | if( pcSlice->getPPS()->getListsModificationPresentFlag() && pcSlice->getNumRpsCurrTempList() > 1) |
---|
[773] | 2102 | #endif |
---|
[56] | 2103 | { |
---|
[608] | 2104 | TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); |
---|
| 2105 | if(!pcSlice->isIntra()) |
---|
[2] | 2106 | { |
---|
[608] | 2107 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0() ? 1 : 0, "ref_pic_list_modification_flag_l0" ); |
---|
| 2108 | if (pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0()) |
---|
[2] | 2109 | { |
---|
[608] | 2110 | Int numRpsCurrTempList0 = pcSlice->getNumRpsCurrTempList(); |
---|
| 2111 | if (numRpsCurrTempList0 > 1) |
---|
[2] | 2112 | { |
---|
[608] | 2113 | Int length = 1; |
---|
| 2114 | numRpsCurrTempList0 --; |
---|
[1200] | 2115 | while ( numRpsCurrTempList0 >>= 1) |
---|
[608] | 2116 | { |
---|
| 2117 | length ++; |
---|
| 2118 | } |
---|
| 2119 | for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_0 ); i++) |
---|
| 2120 | { |
---|
| 2121 | WRITE_CODE( refPicListModification->getRefPicSetIdxL0(i), length, "list_entry_l0"); |
---|
| 2122 | } |
---|
[2] | 2123 | } |
---|
| 2124 | } |
---|
| 2125 | } |
---|
[608] | 2126 | if(pcSlice->isInterB()) |
---|
[1200] | 2127 | { |
---|
[608] | 2128 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1() ? 1 : 0, "ref_pic_list_modification_flag_l1" ); |
---|
| 2129 | if (pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1()) |
---|
[2] | 2130 | { |
---|
[608] | 2131 | Int numRpsCurrTempList1 = pcSlice->getNumRpsCurrTempList(); |
---|
| 2132 | if ( numRpsCurrTempList1 > 1 ) |
---|
[2] | 2133 | { |
---|
[608] | 2134 | Int length = 1; |
---|
| 2135 | numRpsCurrTempList1 --; |
---|
| 2136 | while ( numRpsCurrTempList1 >>= 1) |
---|
| 2137 | { |
---|
| 2138 | length ++; |
---|
| 2139 | } |
---|
| 2140 | for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_1 ); i++) |
---|
| 2141 | { |
---|
| 2142 | WRITE_CODE( refPicListModification->getRefPicSetIdxL1(i), length, "list_entry_l1"); |
---|
| 2143 | } |
---|
[2] | 2144 | } |
---|
| 2145 | } |
---|
| 2146 | } |
---|
| 2147 | } |
---|
[1200] | 2148 | |
---|
[608] | 2149 | if (pcSlice->isInterB()) |
---|
| 2150 | { |
---|
| 2151 | WRITE_FLAG( pcSlice->getMvdL1ZeroFlag() ? 1 : 0, "mvd_l1_zero_flag"); |
---|
[56] | 2152 | } |
---|
[608] | 2153 | |
---|
| 2154 | if(!pcSlice->isIntra()) |
---|
[56] | 2155 | { |
---|
[608] | 2156 | if (!pcSlice->isIntra() && pcSlice->getPPS()->getCabacInitPresentFlag()) |
---|
[2] | 2157 | { |
---|
[608] | 2158 | SliceType sliceType = pcSlice->getSliceType(); |
---|
[1200] | 2159 | SliceType encCABACTableIdx = pcSlice->getEncCABACTableIdx(); |
---|
[608] | 2160 | Bool encCabacInitFlag = (sliceType!=encCABACTableIdx && encCABACTableIdx!=I_SLICE) ? true : false; |
---|
| 2161 | pcSlice->setCabacInitFlag( encCabacInitFlag ); |
---|
| 2162 | WRITE_FLAG( encCabacInitFlag?1:0, "cabac_init_flag" ); |
---|
[2] | 2163 | } |
---|
| 2164 | } |
---|
| 2165 | |
---|
[608] | 2166 | if ( pcSlice->getEnableTMVPFlag() ) |
---|
[2] | 2167 | { |
---|
[608] | 2168 | if ( pcSlice->getSliceType() == B_SLICE ) |
---|
| 2169 | { |
---|
| 2170 | WRITE_FLAG( pcSlice->getColFromL0Flag(), "collocated_from_l0_flag" ); |
---|
| 2171 | } |
---|
| 2172 | |
---|
| 2173 | if ( pcSlice->getSliceType() != I_SLICE && |
---|
| 2174 | ((pcSlice->getColFromL0Flag()==1 && pcSlice->getNumRefIdx(REF_PIC_LIST_0)>1)|| |
---|
| 2175 | (pcSlice->getColFromL0Flag()==0 && pcSlice->getNumRefIdx(REF_PIC_LIST_1)>1))) |
---|
| 2176 | { |
---|
| 2177 | WRITE_UVLC( pcSlice->getColRefIdx(), "collocated_ref_idx" ); |
---|
| 2178 | } |
---|
[2] | 2179 | } |
---|
[608] | 2180 | if ( (pcSlice->getPPS()->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pcSlice->getPPS()->getWPBiPred() && pcSlice->getSliceType()==B_SLICE) ) |
---|
| 2181 | { |
---|
| 2182 | xCodePredWeightTable( pcSlice ); |
---|
| 2183 | } |
---|
[1225] | 2184 | #if NH_3D_IC |
---|
[1179] | 2185 | else if( pcSlice->getViewIndex() && ( pcSlice->getSliceType() == P_SLICE || pcSlice->getSliceType() == B_SLICE ) |
---|
| 2186 | && !pcSlice->getIsDepth() && vps->getNumRefListLayers( layerId ) > 0 |
---|
| 2187 | && getEncTop()->decProcAnnexI() |
---|
| 2188 | ) |
---|
[608] | 2189 | { |
---|
| 2190 | WRITE_FLAG( pcSlice->getApplyIC() ? 1 : 0, "slice_ic_enable_flag" ); |
---|
| 2191 | if( pcSlice->getApplyIC() ) |
---|
| 2192 | { |
---|
[1225] | 2193 | WRITE_FLAG( pcSlice->getIcSkipParseFlag() ? 1 : 0, "slice_ic_disabled_merge_zero_idx_flag" ); |
---|
[608] | 2194 | } |
---|
| 2195 | } |
---|
| 2196 | #endif |
---|
| 2197 | #if H_3D_IV_MERGE |
---|
| 2198 | assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS_MEM); |
---|
[2] | 2199 | #else |
---|
[608] | 2200 | assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS); |
---|
[2] | 2201 | #endif |
---|
[608] | 2202 | if (!pcSlice->isIntra()) |
---|
| 2203 | { |
---|
| 2204 | #if H_3D_IV_MERGE |
---|
[1124] | 2205 | WRITE_UVLC( ( ( pcSlice->getMpiFlag( ) || pcSlice->getIvMvPredFlag( ) || pcSlice->getViewSynthesisPredFlag( ) ) ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS ) - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand"); |
---|
| 2206 | #else |
---|
[608] | 2207 | WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand"); |
---|
| 2208 | #endif |
---|
| 2209 | } |
---|
[56] | 2210 | Int iCode = pcSlice->getSliceQp() - ( pcSlice->getPPS()->getPicInitQPMinus26() + 26 ); |
---|
[1200] | 2211 | WRITE_SVLC( iCode, "slice_qp_delta" ); |
---|
[608] | 2212 | if (pcSlice->getPPS()->getSliceChromaQpFlag()) |
---|
[2] | 2213 | { |
---|
[1200] | 2214 | if (numberValidComponents > COMPONENT_Cb) |
---|
| 2215 | { |
---|
| 2216 | WRITE_SVLC( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb), "slice_cb_qp_offset" ); |
---|
| 2217 | } |
---|
| 2218 | if (numberValidComponents > COMPONENT_Cr) |
---|
| 2219 | { |
---|
| 2220 | WRITE_SVLC( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr), "slice_cr_qp_offset" ); |
---|
| 2221 | } |
---|
| 2222 | assert(numberValidComponents <= COMPONENT_Cr+1); |
---|
[608] | 2223 | } |
---|
[1200] | 2224 | |
---|
| 2225 | if (pcSlice->getPPS()->getPpsRangeExtension().getChromaQpOffsetListEnabledFlag()) |
---|
| 2226 | { |
---|
| 2227 | WRITE_FLAG(pcSlice->getUseChromaQpAdj(), "cu_chroma_qp_offset_enabled_flag"); |
---|
| 2228 | } |
---|
| 2229 | |
---|
[608] | 2230 | if (pcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
---|
| 2231 | { |
---|
| 2232 | if (pcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag() ) |
---|
[2] | 2233 | { |
---|
[608] | 2234 | WRITE_FLAG(pcSlice->getDeblockingFilterOverrideFlag(), "deblocking_filter_override_flag"); |
---|
[2] | 2235 | } |
---|
[608] | 2236 | if (pcSlice->getDeblockingFilterOverrideFlag()) |
---|
[2] | 2237 | { |
---|
[608] | 2238 | WRITE_FLAG(pcSlice->getDeblockingFilterDisable(), "slice_disable_deblocking_filter_flag"); |
---|
| 2239 | if(!pcSlice->getDeblockingFilterDisable()) |
---|
[56] | 2240 | { |
---|
[608] | 2241 | WRITE_SVLC (pcSlice->getDeblockingFilterBetaOffsetDiv2(), "slice_beta_offset_div2"); |
---|
| 2242 | WRITE_SVLC (pcSlice->getDeblockingFilterTcOffsetDiv2(), "slice_tc_offset_div2"); |
---|
[56] | 2243 | } |
---|
[2] | 2244 | } |
---|
[56] | 2245 | } |
---|
[608] | 2246 | |
---|
[1200] | 2247 | Bool isSAOEnabled = pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA) || (chromaEnabled && pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA))); |
---|
[608] | 2248 | Bool isDBFEnabled = (!pcSlice->getDeblockingFilterDisable()); |
---|
| 2249 | |
---|
| 2250 | if(pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
[56] | 2251 | { |
---|
[608] | 2252 | WRITE_FLAG(pcSlice->getLFCrossSliceBoundaryFlag()?1:0, "slice_loop_filter_across_slices_enabled_flag"); |
---|
[56] | 2253 | } |
---|
[1200] | 2254 | #if NH_3D |
---|
[1179] | 2255 | if (getEncTop()->decProcAnnexI() ) |
---|
| 2256 | { |
---|
| 2257 | Int voiInVps = vps->getVoiInVps( pcSlice->getViewIndex() ); |
---|
| 2258 | if( vps->getCpInSliceSegmentHeaderFlag( voiInVps ) && !pcSlice->getIsDepth() ) |
---|
| 2259 | { |
---|
| 2260 | for( Int m = 0; m < vps->getNumCp( voiInVps ); m++ ) |
---|
| 2261 | { |
---|
| 2262 | Int jInVps = vps->getVoiInVps( vps->getCpRefVoi( voiInVps, m )); |
---|
| 2263 | WRITE_SVLC( pcSlice->getCpScale ( jInVps ) , "cp_scale" ); |
---|
| 2264 | WRITE_SVLC( pcSlice->getCpOff ( jInVps ) , "cp_off" ); |
---|
| 2265 | WRITE_SVLC( pcSlice->getCpInvScale( jInVps ) + pcSlice->getCpScale( jInVps ) , "cp_inv_scale_plus_scale" ); |
---|
| 2266 | WRITE_SVLC( pcSlice->getCpInvOff ( jInVps ) + pcSlice->getCpOff ( jInVps ) , "cp_inv_off_plus_off" ); |
---|
| 2267 | } |
---|
| 2268 | } |
---|
| 2269 | } |
---|
| 2270 | #endif |
---|
[1200] | 2271 | |
---|
[608] | 2272 | } |
---|
[1200] | 2273 | #if !NH_MV |
---|
[872] | 2274 | if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag()) |
---|
| 2275 | { |
---|
[1200] | 2276 | WRITE_UVLC(0,"slice_segment_header_extension_length"); |
---|
[872] | 2277 | } |
---|
| 2278 | #else |
---|
| 2279 | if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag()) |
---|
| 2280 | { |
---|
| 2281 | // Derive the value of PocMsbValRequiredFlag |
---|
| 2282 | |
---|
| 2283 | // Determine value of SH extension length. |
---|
| 2284 | Int shExtnLengthInBit = 0; |
---|
| 2285 | if (pcSlice->getPPS()->getPocResetInfoPresentFlag()) |
---|
| 2286 | { |
---|
| 2287 | shExtnLengthInBit += 2; |
---|
| 2288 | } |
---|
| 2289 | if (pcSlice->getPocResetIdc() > 0) |
---|
| 2290 | { |
---|
| 2291 | shExtnLengthInBit += 6; |
---|
| 2292 | } |
---|
| 2293 | if (pcSlice->getPocResetIdc() == 3) |
---|
| 2294 | { |
---|
| 2295 | shExtnLengthInBit += (pcSlice->getSPS()->getBitsForPOC() + 1); |
---|
| 2296 | } |
---|
| 2297 | |
---|
| 2298 | |
---|
[1124] | 2299 | if( !pcSlice->getPocMsbValRequiredFlag() && pcSlice->getVPS()->getVpsPocLsbAlignedFlag() ) |
---|
[872] | 2300 | { |
---|
| 2301 | shExtnLengthInBit++; // For poc_msb_val_present_flag |
---|
| 2302 | } |
---|
| 2303 | else |
---|
| 2304 | { |
---|
| 2305 | if( pcSlice->getPocMsbValRequiredFlag() ) |
---|
| 2306 | { |
---|
| 2307 | pcSlice->setPocMsbValPresentFlag( true ); |
---|
| 2308 | } |
---|
| 2309 | else |
---|
| 2310 | { |
---|
| 2311 | pcSlice->setPocMsbValPresentFlag( false ); |
---|
| 2312 | } |
---|
| 2313 | } |
---|
| 2314 | |
---|
| 2315 | if( pcSlice->getPocMsbValPresentFlag() ) |
---|
| 2316 | { |
---|
| 2317 | // Int iMaxPOClsb = 1<< pcSlice->getSPS()->getBitsForPOC(); currently unused |
---|
| 2318 | |
---|
| 2319 | UInt lengthVal = 1; |
---|
| 2320 | UInt tempVal = pcSlice->getPocMsbVal() + 1; |
---|
| 2321 | assert ( tempVal ); |
---|
| 2322 | while( 1 != tempVal ) |
---|
| 2323 | { |
---|
| 2324 | tempVal >>= 1; |
---|
| 2325 | lengthVal += 2; |
---|
| 2326 | } |
---|
| 2327 | shExtnLengthInBit += lengthVal; |
---|
| 2328 | } |
---|
| 2329 | Int shExtnAdditionalBits = 0; |
---|
| 2330 | if(shExtnLengthInBit % 8 != 0) |
---|
| 2331 | { |
---|
| 2332 | shExtnAdditionalBits = 8 - (shExtnLengthInBit % 8); |
---|
| 2333 | } |
---|
| 2334 | pcSlice->setSliceSegmentHeaderExtensionLength((shExtnLengthInBit + shExtnAdditionalBits) / 8); |
---|
| 2335 | |
---|
| 2336 | |
---|
| 2337 | WRITE_UVLC( pcSlice->getSliceSegmentHeaderExtensionLength( ), "slice_segment_header_extension_length" ); |
---|
| 2338 | UInt posFollSliceSegHeaderExtLen = m_pcBitIf->getNumberOfWrittenBits(); |
---|
| 2339 | if( pcSlice->getPPS()->getPocResetInfoPresentFlag() ) |
---|
| 2340 | { |
---|
| 2341 | WRITE_CODE( pcSlice->getPocResetIdc( ), 2, "poc_reset_idc" ); |
---|
| 2342 | } |
---|
| 2343 | else |
---|
| 2344 | { |
---|
| 2345 | assert( pcSlice->getPocResetIdc( ) == 0 ); |
---|
| 2346 | } |
---|
| 2347 | |
---|
[964] | 2348 | pcSlice->checkPocResetIdc(); |
---|
| 2349 | |
---|
[872] | 2350 | if( pcSlice->getPocResetIdc() != 0 ) |
---|
| 2351 | { |
---|
| 2352 | WRITE_CODE( pcSlice->getPocResetPeriodId( ), 6, "poc_reset_period_id" ); |
---|
| 2353 | } |
---|
| 2354 | |
---|
| 2355 | if( pcSlice->getPocResetIdc() == 3 ) |
---|
| 2356 | { |
---|
| 2357 | WRITE_FLAG( pcSlice->getFullPocResetFlag( ) ? 1 : 0 , "full_poc_reset_flag" ); |
---|
| 2358 | WRITE_CODE( pcSlice->getPocLsbVal( ), pcSlice->getPocLsbValLen() , "poc_lsb_val" ); |
---|
| 2359 | } |
---|
[964] | 2360 | pcSlice->checkPocLsbVal(); |
---|
| 2361 | |
---|
[1124] | 2362 | if( !pcSlice->getPocMsbValRequiredFlag() && pcSlice->getVPS()->getVpsPocLsbAlignedFlag() ) |
---|
[872] | 2363 | { |
---|
| 2364 | WRITE_FLAG( pcSlice->getPocMsbValPresentFlag( ) ? 1 : 0 , "poc_msb_val_present_flag" ); |
---|
| 2365 | } |
---|
[964] | 2366 | else |
---|
| 2367 | { |
---|
| 2368 | assert( pcSlice->getPocMsbValPresentFlag() == pcSlice->inferPocMsbValPresentFlag( ) ); |
---|
| 2369 | } |
---|
[872] | 2370 | |
---|
| 2371 | if( pcSlice->getPocMsbValPresentFlag() ) |
---|
| 2372 | { |
---|
| 2373 | WRITE_UVLC( pcSlice->getPocMsbVal( ), "poc_msb_val" ); |
---|
| 2374 | } |
---|
| 2375 | |
---|
| 2376 | while( ( m_pcBitIf->getNumberOfWrittenBits() - posFollSliceSegHeaderExtLen ) < pcSlice->getSliceSegmentHeaderExtensionLength() * 8 ) |
---|
| 2377 | { |
---|
| 2378 | WRITE_FLAG( 0, "slice_segment_header_extension_data_bit" ); |
---|
| 2379 | } |
---|
| 2380 | |
---|
| 2381 | assert( ( m_pcBitIf->getNumberOfWrittenBits() - posFollSliceSegHeaderExtLen ) == pcSlice->getSliceSegmentHeaderExtensionLength() * 8 ); |
---|
| 2382 | } |
---|
| 2383 | #endif |
---|
[1200] | 2384 | |
---|
[608] | 2385 | } |
---|
[2] | 2386 | |
---|
[1200] | 2387 | Void TEncCavlc::codePTL( const TComPTL* pcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1) |
---|
[608] | 2388 | { |
---|
| 2389 | if(profilePresentFlag) |
---|
[2] | 2390 | { |
---|
[1200] | 2391 | codeProfileTier(pcPTL->getGeneralPTL(), false); // general_... |
---|
[608] | 2392 | } |
---|
[1200] | 2393 | WRITE_CODE( Int(pcPTL->getGeneralPTL()->getLevelIdc()), 8, "general_level_idc" ); |
---|
[608] | 2394 | |
---|
| 2395 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
| 2396 | { |
---|
[1200] | 2397 | #if !NH_MV |
---|
[608] | 2398 | #endif |
---|
[1200] | 2399 | WRITE_FLAG( pcPTL->getSubLayerProfilePresentFlag(i), "sub_layer_profile_present_flag[i]" ); |
---|
| 2400 | #if !NH_MV |
---|
[608] | 2401 | #endif |
---|
| 2402 | WRITE_FLAG( pcPTL->getSubLayerLevelPresentFlag(i), "sub_layer_level_present_flag[i]" ); |
---|
[2] | 2403 | } |
---|
[1200] | 2404 | |
---|
[608] | 2405 | if (maxNumSubLayersMinus1 > 0) |
---|
| 2406 | { |
---|
| 2407 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
| 2408 | { |
---|
| 2409 | WRITE_CODE(0, 2, "reserved_zero_2bits"); |
---|
| 2410 | } |
---|
| 2411 | } |
---|
[1200] | 2412 | |
---|
[608] | 2413 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
| 2414 | { |
---|
[1200] | 2415 | if( pcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
[608] | 2416 | { |
---|
[1200] | 2417 | codeProfileTier(pcPTL->getSubLayerPTL(i), true); // sub_layer_... |
---|
[608] | 2418 | } |
---|
| 2419 | if( pcPTL->getSubLayerLevelPresentFlag(i) ) |
---|
| 2420 | { |
---|
[1200] | 2421 | WRITE_CODE( Int(pcPTL->getSubLayerPTL(i)->getLevelIdc()), 8, "sub_layer_level_idc[i]" ); |
---|
[608] | 2422 | } |
---|
| 2423 | } |
---|
[2] | 2424 | } |
---|
[1200] | 2425 | |
---|
| 2426 | #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
| 2427 | Void TEncCavlc::codeProfileTier( const ProfileTierLevel* ptl, const Bool bIsSubLayer ) |
---|
| 2428 | #define PTL_TRACE_TEXT(txt) bIsSubLayer?("sub_layer_" txt) : ("general_" txt) |
---|
| 2429 | #else |
---|
| 2430 | Void TEncCavlc::codeProfileTier( const ProfileTierLevel* ptl, const Bool /*bIsSubLayer*/ ) |
---|
| 2431 | #define PTL_TRACE_TEXT(txt) txt |
---|
| 2432 | #endif |
---|
[2] | 2433 | { |
---|
[1200] | 2434 | WRITE_CODE( ptl->getProfileSpace(), 2 , PTL_TRACE_TEXT("profile_space" )); |
---|
| 2435 | WRITE_FLAG( ptl->getTierFlag()==Level::HIGH, PTL_TRACE_TEXT("tier_flag" )); |
---|
| 2436 | WRITE_CODE( Int(ptl->getProfileIdc()), 5 , PTL_TRACE_TEXT("profile_idc" )); |
---|
[608] | 2437 | for(Int j = 0; j < 32; j++) |
---|
[56] | 2438 | { |
---|
[1200] | 2439 | WRITE_FLAG( ptl->getProfileCompatibilityFlag(j), PTL_TRACE_TEXT("profile_compatibility_flag[][j]" )); |
---|
[56] | 2440 | } |
---|
[2] | 2441 | |
---|
[1200] | 2442 | WRITE_FLAG(ptl->getProgressiveSourceFlag(), PTL_TRACE_TEXT("progressive_source_flag" )); |
---|
| 2443 | WRITE_FLAG(ptl->getInterlacedSourceFlag(), PTL_TRACE_TEXT("interlaced_source_flag" )); |
---|
| 2444 | WRITE_FLAG(ptl->getNonPackedConstraintFlag(), PTL_TRACE_TEXT("non_packed_constraint_flag" )); |
---|
| 2445 | WRITE_FLAG(ptl->getFrameOnlyConstraintFlag(), PTL_TRACE_TEXT("frame_only_constraint_flag" )); |
---|
| 2446 | |
---|
| 2447 | #if NH_MV |
---|
[1066] | 2448 | if( ptl->getV2ConstraintsPresentFlag() ) |
---|
| 2449 | { |
---|
| 2450 | WRITE_FLAG( ptl->getMax12bitConstraintFlag( ) ? 1 : 0 , "max_12bit_constraint_flag" ); |
---|
| 2451 | WRITE_FLAG( ptl->getMax10bitConstraintFlag( ) ? 1 : 0 , "max_10bit_constraint_flag" ); |
---|
| 2452 | WRITE_FLAG( ptl->getMax8bitConstraintFlag( ) ? 1 : 0 , "max_8bit_constraint_flag" ); |
---|
| 2453 | WRITE_FLAG( ptl->getMax422chromaConstraintFlag( ) ? 1 : 0 , "max_422chroma_constraint_flag" ); |
---|
| 2454 | WRITE_FLAG( ptl->getMax420chromaConstraintFlag( ) ? 1 : 0 , "max_420chroma_constraint_flag" ); |
---|
| 2455 | WRITE_FLAG( ptl->getMaxMonochromeConstraintFlag( ) ? 1 : 0 , "max_monochrome_constraint_flag" ); |
---|
| 2456 | WRITE_FLAG( ptl->getIntraConstraintFlag( ) ? 1 : 0 , "intra_constraint_flag" ); |
---|
| 2457 | WRITE_FLAG( ptl->getOnePictureOnlyConstraintFlag( ) ? 1 : 0 , "one_picture_only_constraint_flag" ); |
---|
| 2458 | WRITE_FLAG( ptl->getLowerBitRateConstraintFlag( ) ? 1 : 0 , "lower_bit_rate_constraint_flag" ); |
---|
| 2459 | WRITE_CODE( 0, 16, "XXX_reserved_zero_34bits[0..15]"); |
---|
| 2460 | WRITE_CODE( 0, 16, "XXX_reserved_zero_34bits[16..31]"); |
---|
| 2461 | WRITE_CODE( 0, 2 , "XXX_reserved_zero_34bits[32..33]"); |
---|
| 2462 | } |
---|
| 2463 | else |
---|
| 2464 | { |
---|
| 2465 | WRITE_CODE( 0, 16, "XXX_reserved_zero_43bits[0..15]"); |
---|
| 2466 | WRITE_CODE( 0, 16, "XXX_reserved_zero_43bits[16..31]"); |
---|
| 2467 | WRITE_CODE( 0, 11, "XXX_reserved_zero_43bits[32..42]"); |
---|
| 2468 | } |
---|
| 2469 | if( ptl->getInbldPresentFlag() ) |
---|
| 2470 | { |
---|
| 2471 | WRITE_FLAG( ptl->getInbldFlag( ) ? 1 : 0 , "inbld_flag" ); |
---|
| 2472 | } |
---|
| 2473 | else |
---|
| 2474 | { |
---|
| 2475 | WRITE_FLAG(0, "reserved_zero_bit"); |
---|
| 2476 | } |
---|
| 2477 | #else |
---|
[1200] | 2478 | if (ptl->getProfileIdc() == Profile::MAINREXT || ptl->getProfileIdc() == Profile::HIGHTHROUGHPUTREXT ) |
---|
| 2479 | { |
---|
| 2480 | const UInt bitDepthConstraint=ptl->getBitDepthConstraint(); |
---|
| 2481 | WRITE_FLAG(bitDepthConstraint<=12, PTL_TRACE_TEXT("max_12bit_constraint_flag" )); |
---|
| 2482 | WRITE_FLAG(bitDepthConstraint<=10, PTL_TRACE_TEXT("max_10bit_constraint_flag" )); |
---|
| 2483 | WRITE_FLAG(bitDepthConstraint<= 8, PTL_TRACE_TEXT("max_8bit_constraint_flag" )); |
---|
| 2484 | const ChromaFormat chromaFmtConstraint=ptl->getChromaFormatConstraint(); |
---|
| 2485 | WRITE_FLAG(chromaFmtConstraint==CHROMA_422||chromaFmtConstraint==CHROMA_420||chromaFmtConstraint==CHROMA_400, PTL_TRACE_TEXT("max_422chroma_constraint_flag" )); |
---|
| 2486 | WRITE_FLAG(chromaFmtConstraint==CHROMA_420||chromaFmtConstraint==CHROMA_400, PTL_TRACE_TEXT("max_420chroma_constraint_flag" )); |
---|
| 2487 | WRITE_FLAG(chromaFmtConstraint==CHROMA_400, PTL_TRACE_TEXT("max_monochrome_constraint_flag")); |
---|
| 2488 | WRITE_FLAG(ptl->getIntraConstraintFlag(), PTL_TRACE_TEXT("intra_constraint_flag" )); |
---|
| 2489 | WRITE_FLAG(ptl->getOnePictureOnlyConstraintFlag(), PTL_TRACE_TEXT("one_picture_only_constraint_flag")); |
---|
| 2490 | WRITE_FLAG(ptl->getLowerBitRateConstraintFlag(), PTL_TRACE_TEXT("lower_bit_rate_constraint_flag" )); |
---|
| 2491 | WRITE_CODE(0 , 16, PTL_TRACE_TEXT("reserved_zero_34bits[0..15]" )); |
---|
| 2492 | WRITE_CODE(0 , 16, PTL_TRACE_TEXT("reserved_zero_34bits[16..31]" )); |
---|
| 2493 | WRITE_CODE(0 , 2, PTL_TRACE_TEXT("reserved_zero_34bits[32..33]" )); |
---|
| 2494 | } |
---|
| 2495 | else |
---|
| 2496 | { |
---|
| 2497 | WRITE_CODE(0x0000 , 16, PTL_TRACE_TEXT("reserved_zero_43bits[0..15]" )); |
---|
| 2498 | WRITE_CODE(0x0000 , 16, PTL_TRACE_TEXT("reserved_zero_43bits[16..31]" )); |
---|
| 2499 | WRITE_CODE(0x000 , 11, PTL_TRACE_TEXT("reserved_zero_43bits[32..42]" )); |
---|
| 2500 | } |
---|
| 2501 | WRITE_FLAG(false, PTL_TRACE_TEXT("inbld_flag" )); |
---|
| 2502 | #undef PTL_TRACE_TEXT |
---|
[1066] | 2503 | #endif |
---|
| 2504 | } |
---|
[608] | 2505 | |
---|
[56] | 2506 | /** |
---|
[1200] | 2507 | * Write tiles and wavefront substreams sizes for the slice header (entry points). |
---|
| 2508 | * |
---|
| 2509 | * \param pSlice TComSlice structure that contains the substream size information. |
---|
[56] | 2510 | */ |
---|
| 2511 | Void TEncCavlc::codeTilesWPPEntryPoint( TComSlice* pSlice ) |
---|
[2] | 2512 | { |
---|
[608] | 2513 | if (!pSlice->getPPS()->getTilesEnabledFlag() && !pSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) |
---|
[2] | 2514 | { |
---|
[56] | 2515 | return; |
---|
[2] | 2516 | } |
---|
[1200] | 2517 | UInt maxOffset = 0; |
---|
| 2518 | for(Int idx=0; idx<pSlice->getNumberOfSubstreamSizes(); idx++) |
---|
[2] | 2519 | { |
---|
[1200] | 2520 | UInt offset=pSlice->getSubstreamSize(idx); |
---|
| 2521 | if ( offset > maxOffset ) |
---|
[2] | 2522 | { |
---|
[1200] | 2523 | maxOffset = offset; |
---|
[2] | 2524 | } |
---|
| 2525 | } |
---|
[1200] | 2526 | |
---|
[56] | 2527 | // Determine number of bits "offsetLenMinus1+1" required for entry point information |
---|
[1200] | 2528 | UInt offsetLenMinus1 = 0; |
---|
[608] | 2529 | while (maxOffset >= (1u << (offsetLenMinus1 + 1))) |
---|
[56] | 2530 | { |
---|
[608] | 2531 | offsetLenMinus1++; |
---|
[1200] | 2532 | assert(offsetLenMinus1 + 1 < 32); |
---|
[2] | 2533 | } |
---|
| 2534 | |
---|
[1200] | 2535 | WRITE_UVLC(pSlice->getNumberOfSubstreamSizes(), "num_entry_point_offsets"); |
---|
| 2536 | if (pSlice->getNumberOfSubstreamSizes()>0) |
---|
[2] | 2537 | { |
---|
[56] | 2538 | WRITE_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
| 2539 | |
---|
[1200] | 2540 | for (UInt idx=0; idx<pSlice->getNumberOfSubstreamSizes(); idx++) |
---|
| 2541 | { |
---|
| 2542 | WRITE_CODE(pSlice->getSubstreamSize(idx)-1, offsetLenMinus1+1, "entry_point_offset_minus1"); |
---|
| 2543 | } |
---|
[2] | 2544 | } |
---|
| 2545 | } |
---|
| 2546 | |
---|
[1200] | 2547 | Void TEncCavlc::codeTerminatingBit ( UInt /*uilsLast*/ ) |
---|
[2] | 2548 | { |
---|
[56] | 2549 | } |
---|
[2] | 2550 | |
---|
[56] | 2551 | Void TEncCavlc::codeSliceFinish () |
---|
| 2552 | { |
---|
| 2553 | } |
---|
[2] | 2554 | |
---|
[1200] | 2555 | Void TEncCavlc::codeMVPIdx ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, RefPicList /*eRefList*/ ) |
---|
[56] | 2556 | { |
---|
| 2557 | assert(0); |
---|
| 2558 | } |
---|
[2] | 2559 | |
---|
[1200] | 2560 | Void TEncCavlc::codePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[56] | 2561 | { |
---|
| 2562 | assert(0); |
---|
| 2563 | } |
---|
[2] | 2564 | |
---|
[1200] | 2565 | Void TEncCavlc::codePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
[56] | 2566 | { |
---|
| 2567 | assert(0); |
---|
| 2568 | } |
---|
[2] | 2569 | |
---|
[1200] | 2570 | Void TEncCavlc::codeMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
[56] | 2571 | { |
---|
| 2572 | assert(0); |
---|
| 2573 | } |
---|
[2] | 2574 | |
---|
[1200] | 2575 | Void TEncCavlc::codeMergeIndex ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
[56] | 2576 | { |
---|
| 2577 | assert(0); |
---|
| 2578 | } |
---|
[2] | 2579 | |
---|
[608] | 2580 | #if H_3D_ARP |
---|
| 2581 | Void TEncCavlc::codeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
[56] | 2582 | { |
---|
| 2583 | assert(0); |
---|
| 2584 | } |
---|
[2] | 2585 | #endif |
---|
[608] | 2586 | |
---|
[1225] | 2587 | #if NH_3D_IC |
---|
[608] | 2588 | Void TEncCavlc::codeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
[443] | 2589 | { |
---|
[608] | 2590 | assert(0); |
---|
[443] | 2591 | } |
---|
| 2592 | #endif |
---|
[2] | 2593 | |
---|
[1200] | 2594 | Void TEncCavlc::codeInterModeFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiEncMode*/ ) |
---|
[56] | 2595 | { |
---|
| 2596 | assert(0); |
---|
| 2597 | } |
---|
[2] | 2598 | |
---|
[1200] | 2599 | Void TEncCavlc::codeCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
[56] | 2600 | { |
---|
| 2601 | assert(0); |
---|
| 2602 | } |
---|
[2] | 2603 | |
---|
[1200] | 2604 | Void TEncCavlc::codeSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
[189] | 2605 | { |
---|
| 2606 | assert(0); |
---|
| 2607 | } |
---|
[1196] | 2608 | #if H_3D |
---|
[1179] | 2609 | Void TEncCavlc::codeDIS( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 2610 | { |
---|
| 2611 | assert(0); |
---|
| 2612 | } |
---|
[1039] | 2613 | #endif |
---|
[1179] | 2614 | |
---|
[1200] | 2615 | Void TEncCavlc::codeSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[56] | 2616 | { |
---|
| 2617 | assert(0); |
---|
| 2618 | } |
---|
[2] | 2619 | |
---|
[1200] | 2620 | Void TEncCavlc::codeTransformSubdivFlag( UInt /*uiSymbol*/, UInt /*uiCtx*/ ) |
---|
[56] | 2621 | { |
---|
| 2622 | assert(0); |
---|
| 2623 | } |
---|
[2] | 2624 | |
---|
[1200] | 2625 | Void TEncCavlc::codeQtCbf( TComTU& /*rTu*/, const ComponentID /*compID*/, const Bool /*lowestLevel*/ ) |
---|
[56] | 2626 | { |
---|
| 2627 | assert(0); |
---|
| 2628 | } |
---|
[2] | 2629 | |
---|
[1200] | 2630 | Void TEncCavlc::codeQtRootCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
[56] | 2631 | { |
---|
| 2632 | assert(0); |
---|
| 2633 | } |
---|
[2] | 2634 | |
---|
[1200] | 2635 | Void TEncCavlc::codeQtCbfZero( TComTU& /*rTu*/, const ChannelType /*chType*/ ) |
---|
[608] | 2636 | { |
---|
| 2637 | assert(0); |
---|
| 2638 | } |
---|
[1200] | 2639 | Void TEncCavlc::codeQtRootCbfZero( ) |
---|
[608] | 2640 | { |
---|
| 2641 | assert(0); |
---|
| 2642 | } |
---|
| 2643 | |
---|
[1200] | 2644 | Void TEncCavlc::codeTransformSkipFlags (TComTU& /*rTu*/, ComponentID /*component*/ ) |
---|
[608] | 2645 | { |
---|
| 2646 | assert(0); |
---|
| 2647 | } |
---|
| 2648 | |
---|
| 2649 | /** Code I_PCM information. |
---|
[56] | 2650 | * \param pcCU pointer to CU |
---|
| 2651 | * \param uiAbsPartIdx CU index |
---|
| 2652 | * \returns Void |
---|
| 2653 | */ |
---|
[1200] | 2654 | Void TEncCavlc::codeIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
[56] | 2655 | { |
---|
| 2656 | assert(0); |
---|
| 2657 | } |
---|
[2] | 2658 | |
---|
[1200] | 2659 | Void TEncCavlc::codeIntraDirLumaAng( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, Bool /*isMultiple*/) |
---|
[56] | 2660 | { |
---|
| 2661 | assert(0); |
---|
| 2662 | } |
---|
[2] | 2663 | |
---|
[1200] | 2664 | Void TEncCavlc::codeIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
[56] | 2665 | { |
---|
| 2666 | assert(0); |
---|
[2] | 2667 | } |
---|
| 2668 | |
---|
[1200] | 2669 | Void TEncCavlc::codeInterDir( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
[2] | 2670 | { |
---|
[56] | 2671 | assert(0); |
---|
| 2672 | } |
---|
[2] | 2673 | |
---|
[1200] | 2674 | Void TEncCavlc::codeRefFrmIdx( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, RefPicList /*eRefList*/ ) |
---|
[56] | 2675 | { |
---|
| 2676 | assert(0); |
---|
[2] | 2677 | } |
---|
| 2678 | |
---|
[1200] | 2679 | Void TEncCavlc::codeMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, RefPicList /*eRefList*/ ) |
---|
[2] | 2680 | { |
---|
[56] | 2681 | assert(0); |
---|
[2] | 2682 | } |
---|
| 2683 | |
---|
[1200] | 2684 | Void TEncCavlc::codeCrossComponentPrediction( TComTU& /*rTu*/, ComponentID /*compID*/ ) |
---|
| 2685 | { |
---|
| 2686 | assert(0); |
---|
| 2687 | } |
---|
| 2688 | |
---|
[56] | 2689 | Void TEncCavlc::codeDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 2690 | { |
---|
| 2691 | Int iDQp = pcCU->getQP( uiAbsPartIdx ) - pcCU->getRefQP( uiAbsPartIdx ); |
---|
| 2692 | |
---|
[1200] | 2693 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA); |
---|
[56] | 2694 | iDQp = (iDQp + 78 + qpBdOffsetY + (qpBdOffsetY/2)) % (52 + qpBdOffsetY) - 26 - (qpBdOffsetY/2); |
---|
| 2695 | |
---|
| 2696 | xWriteSvlc( iDQp ); |
---|
[1200] | 2697 | |
---|
[56] | 2698 | return; |
---|
| 2699 | } |
---|
| 2700 | |
---|
[1200] | 2701 | Void TEncCavlc::codeChromaQpAdjustment( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
[56] | 2702 | { |
---|
| 2703 | assert(0); |
---|
| 2704 | } |
---|
| 2705 | |
---|
[1200] | 2706 | Void TEncCavlc::codeCoeffNxN ( TComTU& /*rTu*/, TCoeff* /*pcCoef*/, const ComponentID /*compID*/ ) |
---|
[2] | 2707 | { |
---|
[1200] | 2708 | assert(0); |
---|
| 2709 | } |
---|
| 2710 | |
---|
| 2711 | Void TEncCavlc::estBit( estBitsSbacStruct* /*pcEstBitsCabac*/, Int /*width*/, Int /*height*/, ChannelType /*chType*/ ) |
---|
| 2712 | { |
---|
[2] | 2713 | // printf("error : no VLC mode support in this version\n"); |
---|
| 2714 | return; |
---|
| 2715 | } |
---|
| 2716 | |
---|
| 2717 | // ==================================================================================================================== |
---|
| 2718 | // Protected member functions |
---|
| 2719 | // ==================================================================================================================== |
---|
| 2720 | |
---|
[1200] | 2721 | //! Code weighted prediction tables |
---|
[56] | 2722 | Void TEncCavlc::xCodePredWeightTable( TComSlice* pcSlice ) |
---|
[2] | 2723 | { |
---|
[1200] | 2724 | WPScalingParam *wp; |
---|
| 2725 | const ChromaFormat format = pcSlice->getPic()->getChromaFormat(); |
---|
| 2726 | const UInt numberValidComponents = getNumberValidComponents(format); |
---|
| 2727 | const Bool bChroma = isChromaEnabled(format); |
---|
| 2728 | const Int iNbRef = (pcSlice->getSliceType() == B_SLICE ) ? (2) : (1); |
---|
| 2729 | Bool bDenomCoded = false; |
---|
| 2730 | UInt uiTotalSignalledWeightFlags = 0; |
---|
| 2731 | |
---|
[608] | 2732 | if ( (pcSlice->getSliceType()==P_SLICE && pcSlice->getPPS()->getUseWP()) || (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPred()) ) |
---|
| 2733 | { |
---|
[1200] | 2734 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) // loop over l0 and l1 syntax elements |
---|
[2] | 2735 | { |
---|
[56] | 2736 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
[608] | 2737 | |
---|
[1200] | 2738 | // NOTE: wp[].uiLog2WeightDenom and wp[].bPresentFlag are actually per-channel-type settings. |
---|
| 2739 | |
---|
| 2740 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
[2] | 2741 | { |
---|
[56] | 2742 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
[1200] | 2743 | if ( !bDenomCoded ) |
---|
[2] | 2744 | { |
---|
[56] | 2745 | Int iDeltaDenom; |
---|
[1200] | 2746 | WRITE_UVLC( wp[COMPONENT_Y].uiLog2WeightDenom, "luma_log2_weight_denom" ); |
---|
[2] | 2747 | |
---|
[56] | 2748 | if( bChroma ) |
---|
[2] | 2749 | { |
---|
[1200] | 2750 | assert(wp[COMPONENT_Cb].uiLog2WeightDenom == wp[COMPONENT_Cr].uiLog2WeightDenom); // check the channel-type settings are consistent across components. |
---|
| 2751 | iDeltaDenom = (wp[COMPONENT_Cb].uiLog2WeightDenom - wp[COMPONENT_Y].uiLog2WeightDenom); |
---|
| 2752 | WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); |
---|
[2] | 2753 | } |
---|
[56] | 2754 | bDenomCoded = true; |
---|
| 2755 | } |
---|
[1200] | 2756 | WRITE_FLAG( wp[COMPONENT_Y].bPresentFlag, iNumRef==0?"luma_weight_l0_flag[i]":"luma_weight_l1_flag[i]" ); |
---|
| 2757 | uiTotalSignalledWeightFlags += wp[COMPONENT_Y].bPresentFlag; |
---|
[608] | 2758 | } |
---|
[1200] | 2759 | if (bChroma) |
---|
[608] | 2760 | { |
---|
[1200] | 2761 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
[608] | 2762 | { |
---|
| 2763 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
[1200] | 2764 | assert(wp[COMPONENT_Cb].bPresentFlag == wp[COMPONENT_Cr].bPresentFlag); // check the channel-type settings are consistent across components. |
---|
| 2765 | WRITE_FLAG( wp[COMPONENT_Cb].bPresentFlag, iNumRef==0?"chroma_weight_l0_flag[i]":"chroma_weight_l1_flag[i]" ); |
---|
| 2766 | uiTotalSignalledWeightFlags += 2*wp[COMPONENT_Cb].bPresentFlag; |
---|
[608] | 2767 | } |
---|
| 2768 | } |
---|
[2] | 2769 | |
---|
[1200] | 2770 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
[608] | 2771 | { |
---|
| 2772 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
[1200] | 2773 | if ( wp[COMPONENT_Y].bPresentFlag ) |
---|
[56] | 2774 | { |
---|
[1200] | 2775 | Int iDeltaWeight = (wp[COMPONENT_Y].iWeight - (1<<wp[COMPONENT_Y].uiLog2WeightDenom)); |
---|
| 2776 | WRITE_SVLC( iDeltaWeight, iNumRef==0?"delta_luma_weight_l0[i]":"delta_luma_weight_l1[i]" ); |
---|
| 2777 | WRITE_SVLC( wp[COMPONENT_Y].iOffset, iNumRef==0?"luma_offset_l0[i]":"luma_offset_l1[i]" ); |
---|
[56] | 2778 | } |
---|
[2] | 2779 | |
---|
[1200] | 2780 | if ( bChroma ) |
---|
[56] | 2781 | { |
---|
[1200] | 2782 | if ( wp[COMPONENT_Cb].bPresentFlag ) |
---|
[2] | 2783 | { |
---|
[1200] | 2784 | for ( Int j = COMPONENT_Cb ; j < numberValidComponents ; j++ ) |
---|
[2] | 2785 | { |
---|
[1200] | 2786 | assert(wp[COMPONENT_Cb].uiLog2WeightDenom == wp[COMPONENT_Cr].uiLog2WeightDenom); |
---|
| 2787 | Int iDeltaWeight = (wp[j].iWeight - (1<<wp[COMPONENT_Cb].uiLog2WeightDenom)); |
---|
| 2788 | WRITE_SVLC( iDeltaWeight, iNumRef==0?"delta_chroma_weight_l0[i]":"delta_chroma_weight_l1[i]" ); |
---|
[56] | 2789 | |
---|
[1200] | 2790 | Int range=pcSlice->getSPS()->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag() ? (1<<pcSlice->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA))/2 : 128; |
---|
| 2791 | Int pred = ( range - ( ( range*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
[608] | 2792 | Int iDeltaChroma = (wp[j].iOffset - pred); |
---|
[1200] | 2793 | WRITE_SVLC( iDeltaChroma, iNumRef==0?"delta_chroma_offset_l0[i]":"delta_chroma_offset_l1[i]" ); |
---|
[2] | 2794 | } |
---|
| 2795 | } |
---|
| 2796 | } |
---|
| 2797 | } |
---|
| 2798 | } |
---|
[608] | 2799 | assert(uiTotalSignalledWeightFlags<=24); |
---|
[2] | 2800 | } |
---|
[56] | 2801 | } |
---|
[2] | 2802 | |
---|
[56] | 2803 | /** code quantization matrix |
---|
| 2804 | * \param scalingList quantization matrix information |
---|
| 2805 | */ |
---|
[1200] | 2806 | Void TEncCavlc::codeScalingList( const TComScalingList &scalingList ) |
---|
[56] | 2807 | { |
---|
[1200] | 2808 | //for each size |
---|
| 2809 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2810 | { |
---|
| 2811 | const Int predListStep = (sizeId == SCALING_LIST_32x32? (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) : 1); // if 32x32, skip over chroma entries. |
---|
[2] | 2812 | |
---|
[1200] | 2813 | for(UInt listId = 0; listId < SCALING_LIST_NUM; listId+=predListStep) |
---|
[2] | 2814 | { |
---|
[1200] | 2815 | Bool scalingListPredModeFlag = scalingList.getScalingListPredModeFlag(sizeId, listId); |
---|
| 2816 | WRITE_FLAG( scalingListPredModeFlag, "scaling_list_pred_mode_flag" ); |
---|
| 2817 | if(!scalingListPredModeFlag)// Copy Mode |
---|
[2] | 2818 | { |
---|
[1200] | 2819 | if (sizeId == SCALING_LIST_32x32) |
---|
[2] | 2820 | { |
---|
[1200] | 2821 | // adjust the code, to cope with the missing chroma entries |
---|
| 2822 | WRITE_UVLC( ((Int)listId - (Int)scalingList.getRefMatrixId (sizeId,listId)) / (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES), "scaling_list_pred_matrix_id_delta"); |
---|
[2] | 2823 | } |
---|
[1200] | 2824 | else |
---|
[2] | 2825 | { |
---|
[1200] | 2826 | WRITE_UVLC( (Int)listId - (Int)scalingList.getRefMatrixId (sizeId,listId), "scaling_list_pred_matrix_id_delta"); |
---|
[2] | 2827 | } |
---|
| 2828 | } |
---|
[1200] | 2829 | else// DPCM Mode |
---|
| 2830 | { |
---|
| 2831 | xCodeScalingList(&scalingList, sizeId, listId); |
---|
| 2832 | } |
---|
[2] | 2833 | } |
---|
[1200] | 2834 | } |
---|
[2] | 2835 | return; |
---|
| 2836 | } |
---|
[56] | 2837 | /** code DPCM |
---|
| 2838 | * \param scalingList quantization matrix information |
---|
[1200] | 2839 | * \param sizeId size index |
---|
| 2840 | * \param listId list index |
---|
[56] | 2841 | */ |
---|
[1200] | 2842 | Void TEncCavlc::xCodeScalingList(const TComScalingList* scalingList, UInt sizeId, UInt listId) |
---|
[2] | 2843 | { |
---|
[56] | 2844 | Int coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
[1200] | 2845 | UInt* scan = g_scanOrder[SCAN_UNGROUPED][SCAN_DIAG][sizeId==0 ? 2 : 3][sizeId==0 ? 2 : 3]; |
---|
[56] | 2846 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
| 2847 | Int data; |
---|
[1200] | 2848 | const Int *src = scalingList->getScalingListAddress(sizeId, listId); |
---|
[56] | 2849 | if( sizeId > SCALING_LIST_8x8 ) |
---|
[2] | 2850 | { |
---|
[56] | 2851 | WRITE_SVLC( scalingList->getScalingListDC(sizeId,listId) - 8, "scaling_list_dc_coef_minus8"); |
---|
[608] | 2852 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
[2] | 2853 | } |
---|
[56] | 2854 | for(Int i=0;i<coefNum;i++) |
---|
[2] | 2855 | { |
---|
[56] | 2856 | data = src[scan[i]] - nextCoef; |
---|
| 2857 | nextCoef = src[scan[i]]; |
---|
| 2858 | if(data > 127) |
---|
[2] | 2859 | { |
---|
[56] | 2860 | data = data - 256; |
---|
[2] | 2861 | } |
---|
[56] | 2862 | if(data < -128) |
---|
[2] | 2863 | { |
---|
[56] | 2864 | data = data + 256; |
---|
[2] | 2865 | } |
---|
| 2866 | |
---|
[56] | 2867 | WRITE_SVLC( data, "scaling_list_delta_coef"); |
---|
[2] | 2868 | } |
---|
[608] | 2869 | } |
---|
| 2870 | Bool TEncCavlc::findMatchingLTRP ( TComSlice* pcSlice, UInt *ltrpsIndex, Int ltrpPOC, Bool usedFlag ) |
---|
| 2871 | { |
---|
| 2872 | // Bool state = true, state2 = false; |
---|
[655] | 2873 | Int lsb = ltrpPOC & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); |
---|
[608] | 2874 | for (Int k = 0; k < pcSlice->getSPS()->getNumLongTermRefPicSPS(); k++) |
---|
| 2875 | { |
---|
| 2876 | if ( (lsb == pcSlice->getSPS()->getLtRefPicPocLsbSps(k)) && (usedFlag == pcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(k)) ) |
---|
| 2877 | { |
---|
| 2878 | *ltrpsIndex = k; |
---|
| 2879 | return true; |
---|
| 2880 | } |
---|
[2] | 2881 | } |
---|
[608] | 2882 | return false; |
---|
[2] | 2883 | } |
---|
[189] | 2884 | |
---|
[1200] | 2885 | Void TEncCavlc::codeExplicitRdpcmMode( TComTU& /*rTu*/, const ComponentID /*compID*/ ) |
---|
| 2886 | { |
---|
| 2887 | assert(0); |
---|
| 2888 | } |
---|
| 2889 | |
---|
[655] | 2890 | #if H_3D_INTER_SDC |
---|
[833] | 2891 | Void TEncCavlc::codeDeltaDC( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 2892 | { |
---|
| 2893 | assert(0); |
---|
| 2894 | } |
---|
| 2895 | |
---|
| 2896 | Void TEncCavlc::codeSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 2897 | { |
---|
| 2898 | assert(0); |
---|
| 2899 | } |
---|
[608] | 2900 | |
---|
[189] | 2901 | #endif |
---|
[833] | 2902 | |
---|
| 2903 | #if H_3D_DBBP |
---|
| 2904 | Void TEncCavlc::codeDBBPFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 2905 | { |
---|
| 2906 | assert(0); |
---|
| 2907 | } |
---|
| 2908 | #endif |
---|
[1200] | 2909 | |
---|
| 2910 | |
---|
[56] | 2911 | //! \} |
---|