[313] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
[1029] | 4 | * granted under this license. |
---|
[313] | 5 | * |
---|
[595] | 6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
[313] | 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
| 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | /** \file TEncCavlc.cpp |
---|
| 35 | \brief CAVLC encoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "../TLibCommon/CommonDef.h" |
---|
| 39 | #include "TEncCavlc.h" |
---|
| 40 | #include "SEIwrite.h" |
---|
| 41 | |
---|
| 42 | //! \ingroup TLibEncoder |
---|
| 43 | //! \{ |
---|
| 44 | |
---|
| 45 | #if ENC_DEC_TRACE |
---|
| 46 | |
---|
| 47 | Void xTraceSPSHeader (TComSPS *pSPS) |
---|
| 48 | { |
---|
| 49 | fprintf( g_hTrace, "=========== Sequence Parameter Set ID: %d ===========\n", pSPS->getSPSId() ); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | Void xTracePPSHeader (TComPPS *pPPS) |
---|
| 53 | { |
---|
| 54 | fprintf( g_hTrace, "=========== Picture Parameter Set ID: %d ===========\n", pPPS->getPPSId() ); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | Void xTraceSliceHeader (TComSlice *pSlice) |
---|
| 58 | { |
---|
| 59 | fprintf( g_hTrace, "=========== Slice ===========\n"); |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | #endif |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | // ==================================================================================================================== |
---|
| 67 | // Constructor / destructor / create / destroy |
---|
| 68 | // ==================================================================================================================== |
---|
| 69 | |
---|
| 70 | TEncCavlc::TEncCavlc() |
---|
| 71 | { |
---|
| 72 | m_pcBitIf = NULL; |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | TEncCavlc::~TEncCavlc() |
---|
| 76 | { |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | // ==================================================================================================================== |
---|
| 81 | // Public member functions |
---|
| 82 | // ==================================================================================================================== |
---|
| 83 | |
---|
| 84 | Void TEncCavlc::resetEntropy() |
---|
| 85 | { |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | Void TEncCavlc::codeDFFlag(UInt uiCode, const Char *pSymbolName) |
---|
| 90 | { |
---|
| 91 | WRITE_FLAG(uiCode, pSymbolName); |
---|
| 92 | } |
---|
| 93 | Void TEncCavlc::codeDFSvlc(Int iCode, const Char *pSymbolName) |
---|
| 94 | { |
---|
| 95 | WRITE_SVLC(iCode, pSymbolName); |
---|
| 96 | } |
---|
| 97 | |
---|
[1235] | 98 | Void TEncCavlc::codeShortTermRefPicSet( const TComReferencePictureSet* rps, Bool calledFromSliceHeader, Int idx) |
---|
[313] | 99 | { |
---|
| 100 | #if PRINT_RPS_INFO |
---|
| 101 | Int lastBits = getNumberOfWrittenBits(); |
---|
| 102 | #endif |
---|
| 103 | if (idx > 0) |
---|
| 104 | { |
---|
| 105 | WRITE_FLAG( rps->getInterRPSPrediction(), "inter_ref_pic_set_prediction_flag" ); // inter_RPS_prediction_flag |
---|
| 106 | } |
---|
| 107 | if (rps->getInterRPSPrediction()) |
---|
| 108 | { |
---|
| 109 | Int deltaRPS = rps->getDeltaRPS(); |
---|
| 110 | if(calledFromSliceHeader) |
---|
| 111 | { |
---|
| 112 | WRITE_UVLC( rps->getDeltaRIdxMinus1(), "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1 |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | WRITE_CODE( (deltaRPS >=0 ? 0: 1), 1, "delta_rps_sign" ); //delta_rps_sign |
---|
| 116 | WRITE_UVLC( abs(deltaRPS) - 1, "abs_delta_rps_minus1"); // absolute delta RPS minus 1 |
---|
| 117 | |
---|
| 118 | for(Int j=0; j < rps->getNumRefIdc(); j++) |
---|
| 119 | { |
---|
| 120 | Int refIdc = rps->getRefIdc(j); |
---|
[1029] | 121 | WRITE_CODE( (refIdc==1? 1: 0), 1, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 |
---|
| 122 | if (refIdc != 1) |
---|
[313] | 123 | { |
---|
| 124 | WRITE_CODE( refIdc>>1, 1, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise. |
---|
| 125 | } |
---|
| 126 | } |
---|
| 127 | } |
---|
| 128 | else |
---|
| 129 | { |
---|
| 130 | WRITE_UVLC( rps->getNumberOfNegativePictures(), "num_negative_pics" ); |
---|
| 131 | WRITE_UVLC( rps->getNumberOfPositivePictures(), "num_positive_pics" ); |
---|
| 132 | Int prev = 0; |
---|
| 133 | for(Int j=0 ; j < rps->getNumberOfNegativePictures(); j++) |
---|
| 134 | { |
---|
| 135 | WRITE_UVLC( prev-rps->getDeltaPOC(j)-1, "delta_poc_s0_minus1" ); |
---|
| 136 | prev = rps->getDeltaPOC(j); |
---|
[1029] | 137 | WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s0_flag"); |
---|
[313] | 138 | } |
---|
| 139 | prev = 0; |
---|
| 140 | for(Int j=rps->getNumberOfNegativePictures(); j < rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); j++) |
---|
| 141 | { |
---|
| 142 | WRITE_UVLC( rps->getDeltaPOC(j)-prev-1, "delta_poc_s1_minus1" ); |
---|
| 143 | prev = rps->getDeltaPOC(j); |
---|
[1029] | 144 | WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s1_flag" ); |
---|
[313] | 145 | } |
---|
| 146 | } |
---|
| 147 | |
---|
| 148 | #if PRINT_RPS_INFO |
---|
| 149 | printf("irps=%d (%2d bits) ", rps->getInterRPSPrediction(), getNumberOfWrittenBits() - lastBits); |
---|
| 150 | rps->printDeltaPOC(); |
---|
| 151 | #endif |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | |
---|
[1212] | 155 | #if CGS_3D_ASYMLUT |
---|
[1235] | 156 | Void TEncCavlc::codePPS( const TComPPS* pcPPS, TEnc3DAsymLUT * pc3DAsymLUT ) |
---|
| 157 | #else |
---|
| 158 | Void TEncCavlc::codePPS( const TComPPS* pcPPS ) |
---|
[713] | 159 | #endif |
---|
[313] | 160 | { |
---|
[1029] | 161 | #if ENC_DEC_TRACE |
---|
[313] | 162 | xTracePPSHeader (pcPPS); |
---|
| 163 | #endif |
---|
[1029] | 164 | |
---|
[313] | 165 | WRITE_UVLC( pcPPS->getPPSId(), "pps_pic_parameter_set_id" ); |
---|
| 166 | WRITE_UVLC( pcPPS->getSPSId(), "pps_seq_parameter_set_id" ); |
---|
| 167 | WRITE_FLAG( pcPPS->getDependentSliceSegmentsEnabledFlag() ? 1 : 0, "dependent_slice_segments_enabled_flag" ); |
---|
| 168 | WRITE_FLAG( pcPPS->getOutputFlagPresentFlag() ? 1 : 0, "output_flag_present_flag" ); |
---|
| 169 | WRITE_CODE( pcPPS->getNumExtraSliceHeaderBits(), 3, "num_extra_slice_header_bits"); |
---|
| 170 | WRITE_FLAG( pcPPS->getSignHideFlag(), "sign_data_hiding_flag" ); |
---|
| 171 | WRITE_FLAG( pcPPS->getCabacInitPresentFlag() ? 1 : 0, "cabac_init_present_flag" ); |
---|
| 172 | WRITE_UVLC( pcPPS->getNumRefIdxL0DefaultActive()-1, "num_ref_idx_l0_default_active_minus1"); |
---|
| 173 | WRITE_UVLC( pcPPS->getNumRefIdxL1DefaultActive()-1, "num_ref_idx_l1_default_active_minus1"); |
---|
| 174 | |
---|
| 175 | WRITE_SVLC( pcPPS->getPicInitQPMinus26(), "init_qp_minus26"); |
---|
| 176 | WRITE_FLAG( pcPPS->getConstrainedIntraPred() ? 1 : 0, "constrained_intra_pred_flag" ); |
---|
[1029] | 177 | WRITE_FLAG( pcPPS->getUseTransformSkip() ? 1 : 0, "transform_skip_enabled_flag" ); |
---|
[313] | 178 | WRITE_FLAG( pcPPS->getUseDQP() ? 1 : 0, "cu_qp_delta_enabled_flag" ); |
---|
| 179 | if ( pcPPS->getUseDQP() ) |
---|
| 180 | { |
---|
| 181 | WRITE_UVLC( pcPPS->getMaxCuDQPDepth(), "diff_cu_qp_delta_depth" ); |
---|
| 182 | } |
---|
[1029] | 183 | |
---|
[1235] | 184 | WRITE_SVLC( pcPPS->getQpOffset(COMPONENT_Cb), "pps_cb_qp_offset" ); |
---|
| 185 | WRITE_SVLC( pcPPS->getQpOffset(COMPONENT_Cr), "pps_cr_qp_offset" ); |
---|
[1029] | 186 | |
---|
[313] | 187 | WRITE_FLAG( pcPPS->getSliceChromaQpFlag() ? 1 : 0, "pps_slice_chroma_qp_offsets_present_flag" ); |
---|
| 188 | |
---|
| 189 | WRITE_FLAG( pcPPS->getUseWP() ? 1 : 0, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) |
---|
| 190 | WRITE_FLAG( pcPPS->getWPBiPred() ? 1 : 0, "weighted_bipred_flag" ); // Use of Weighting Bi-Prediction (B_SLICE) |
---|
| 191 | WRITE_FLAG( pcPPS->getTransquantBypassEnableFlag() ? 1 : 0, "transquant_bypass_enable_flag" ); |
---|
| 192 | WRITE_FLAG( pcPPS->getTilesEnabledFlag() ? 1 : 0, "tiles_enabled_flag" ); |
---|
| 193 | WRITE_FLAG( pcPPS->getEntropyCodingSyncEnabledFlag() ? 1 : 0, "entropy_coding_sync_enabled_flag" ); |
---|
| 194 | if( pcPPS->getTilesEnabledFlag() ) |
---|
| 195 | { |
---|
[823] | 196 | WRITE_UVLC( pcPPS->getNumTileColumnsMinus1(), "num_tile_columns_minus1" ); |
---|
[1029] | 197 | WRITE_UVLC( pcPPS->getNumTileRowsMinus1(), "num_tile_rows_minus1" ); |
---|
[823] | 198 | WRITE_FLAG( pcPPS->getTileUniformSpacingFlag(), "uniform_spacing_flag" ); |
---|
| 199 | if( !pcPPS->getTileUniformSpacingFlag() ) |
---|
[313] | 200 | { |
---|
[823] | 201 | for(UInt i=0; i<pcPPS->getNumTileColumnsMinus1(); i++) |
---|
[313] | 202 | { |
---|
[823] | 203 | WRITE_UVLC( pcPPS->getTileColumnWidth(i)-1, "column_width_minus1" ); |
---|
[313] | 204 | } |
---|
[1029] | 205 | for(UInt i=0; i<pcPPS->getNumTileRowsMinus1(); i++) |
---|
[313] | 206 | { |
---|
[823] | 207 | WRITE_UVLC( pcPPS->getTileRowHeight(i)-1, "row_height_minus1" ); |
---|
[313] | 208 | } |
---|
| 209 | } |
---|
[1029] | 210 | if(pcPPS->getNumTileColumnsMinus1() !=0 || pcPPS->getNumTileRowsMinus1() !=0) |
---|
[313] | 211 | { |
---|
| 212 | WRITE_FLAG( pcPPS->getLoopFilterAcrossTilesEnabledFlag()?1 : 0, "loop_filter_across_tiles_enabled_flag"); |
---|
| 213 | } |
---|
| 214 | } |
---|
| 215 | WRITE_FLAG( pcPPS->getLoopFilterAcrossSlicesEnabledFlag()?1 : 0, "loop_filter_across_slices_enabled_flag"); |
---|
| 216 | WRITE_FLAG( pcPPS->getDeblockingFilterControlPresentFlag()?1 : 0, "deblocking_filter_control_present_flag"); |
---|
| 217 | if(pcPPS->getDeblockingFilterControlPresentFlag()) |
---|
| 218 | { |
---|
[1029] | 219 | WRITE_FLAG( pcPPS->getDeblockingFilterOverrideEnabledFlag() ? 1 : 0, "deblocking_filter_override_enabled_flag" ); |
---|
[313] | 220 | WRITE_FLAG( pcPPS->getPicDisableDeblockingFilterFlag() ? 1 : 0, "pps_disable_deblocking_filter_flag" ); |
---|
| 221 | if(!pcPPS->getPicDisableDeblockingFilterFlag()) |
---|
| 222 | { |
---|
| 223 | WRITE_SVLC( pcPPS->getDeblockingFilterBetaOffsetDiv2(), "pps_beta_offset_div2" ); |
---|
| 224 | WRITE_SVLC( pcPPS->getDeblockingFilterTcOffsetDiv2(), "pps_tc_offset_div2" ); |
---|
| 225 | } |
---|
| 226 | } |
---|
[1029] | 227 | WRITE_FLAG( pcPPS->getScalingListPresentFlag() ? 1 : 0, "pps_scaling_list_data_present_flag" ); |
---|
| 228 | if( pcPPS->getScalingListPresentFlag() ) |
---|
[540] | 229 | { |
---|
[1235] | 230 | codeScalingList( pcPPS->getScalingList() ); |
---|
[540] | 231 | } |
---|
[1029] | 232 | WRITE_FLAG( pcPPS->getListsModificationPresentFlag(), "lists_modification_present_flag"); |
---|
| 233 | WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2"); |
---|
| 234 | WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_segment_header_extension_present_flag"); |
---|
[540] | 235 | |
---|
[1029] | 236 | Bool pps_extension_present_flag=false; |
---|
| 237 | Bool pps_extension_flags[NUM_PPS_EXTENSION_FLAGS]={false}; |
---|
[540] | 238 | |
---|
[1029] | 239 | pps_extension_flags[PPS_EXT__REXT] = ( |
---|
| 240 | ( pcPPS->getUseTransformSkip() && (pcPPS->getTransformSkipLog2MaxSize() != 2)) |
---|
| 241 | || pcPPS->getUseCrossComponentPrediction() |
---|
| 242 | || ( pcPPS->getChromaQpAdjTableSize() > 0 ) |
---|
| 243 | || ( pcPPS->getSaoOffsetBitShift(CHANNEL_TYPE_LUMA) !=0 ) || ( pcPPS->getSaoOffsetBitShift(CHANNEL_TYPE_CHROMA) !=0 ) |
---|
| 244 | ) |
---|
| 245 | ; |
---|
| 246 | |
---|
| 247 | // Other PPS extension flags checked here. |
---|
| 248 | |
---|
| 249 | #if SVC_EXTENSION |
---|
| 250 | pps_extension_flags[PPS_EXT__MLAYER] = pcPPS->getExtensionFlag() ? 1 : 0; |
---|
[1212] | 251 | #if CGS_3D_ASYMLUT |
---|
[1029] | 252 | UInt bits = 0; |
---|
[442] | 253 | #endif |
---|
[898] | 254 | #endif |
---|
[442] | 255 | |
---|
[1029] | 256 | for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) |
---|
[313] | 257 | { |
---|
[1029] | 258 | pps_extension_present_flag|=pps_extension_flags[i]; |
---|
[540] | 259 | } |
---|
[442] | 260 | |
---|
[1029] | 261 | WRITE_FLAG( (pps_extension_present_flag?1:0), "pps_extension_present_flag" ); |
---|
[815] | 262 | |
---|
[1029] | 263 | if (pps_extension_present_flag) |
---|
[644] | 264 | { |
---|
[1029] | 265 | for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) |
---|
[644] | 266 | { |
---|
[1029] | 267 | WRITE_FLAG( pps_extension_flags[i]?1:0, "pps_extension_flag[]" ); |
---|
[644] | 268 | } |
---|
[1029] | 269 | |
---|
| 270 | for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. |
---|
[644] | 271 | { |
---|
[1029] | 272 | if (pps_extension_flags[i]) |
---|
[849] | 273 | { |
---|
[1029] | 274 | switch (PPSExtensionFlagIndex(i)) |
---|
[849] | 275 | { |
---|
[1029] | 276 | case PPS_EXT__REXT: |
---|
[898] | 277 | |
---|
[1029] | 278 | if (pcPPS->getUseTransformSkip()) |
---|
| 279 | { |
---|
| 280 | WRITE_UVLC( pcPPS->getTransformSkipLog2MaxSize()-2, "log2_transform_skip_max_size_minus2"); |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | WRITE_FLAG((pcPPS->getUseCrossComponentPrediction() ? 1 : 0), "cross_component_prediction_flag" ); |
---|
| 284 | |
---|
| 285 | WRITE_FLAG(UInt(pcPPS->getChromaQpAdjTableSize() > 0), "chroma_qp_adjustment_enabled_flag" ); |
---|
| 286 | if (pcPPS->getChromaQpAdjTableSize() > 0) |
---|
| 287 | { |
---|
| 288 | WRITE_UVLC(pcPPS->getMaxCuChromaQpAdjDepth(), "diff_cu_chroma_qp_adjustment_depth"); |
---|
| 289 | WRITE_UVLC(pcPPS->getChromaQpAdjTableSize() - 1, "chroma_qp_adjustment_table_size_minus1"); |
---|
| 290 | /* skip zero index */ |
---|
| 291 | for (Int chromaQpAdjustmentIndex = 1; chromaQpAdjustmentIndex <= pcPPS->getChromaQpAdjTableSize(); chromaQpAdjustmentIndex++) |
---|
| 292 | { |
---|
| 293 | WRITE_SVLC(pcPPS->getChromaQpAdjTableAt(chromaQpAdjustmentIndex).u.comp.CbOffset, "cb_qp_adjustnemt[i]"); |
---|
| 294 | WRITE_SVLC(pcPPS->getChromaQpAdjTableAt(chromaQpAdjustmentIndex).u.comp.CrOffset, "cr_qp_adjustnemt[i]"); |
---|
| 295 | } |
---|
| 296 | } |
---|
| 297 | |
---|
| 298 | WRITE_UVLC( pcPPS->getSaoOffsetBitShift(CHANNEL_TYPE_LUMA), "sao_luma_bit_shift" ); |
---|
| 299 | WRITE_UVLC( pcPPS->getSaoOffsetBitShift(CHANNEL_TYPE_CHROMA), "sao_chroma_bit_shift" ); |
---|
| 300 | break; |
---|
| 301 | #if SVC_EXTENSION |
---|
| 302 | case PPS_EXT__MLAYER: |
---|
| 303 | WRITE_FLAG( pcPPS->getPocResetInfoPresentFlag() ? 1 : 0, "poc_reset_info_present_flag" ); |
---|
[1223] | 304 | |
---|
[1029] | 305 | WRITE_FLAG( pcPPS->getInferScalingListFlag() ? 1 : 0, "pps_infer_scaling_list_flag" ); |
---|
| 306 | if( pcPPS->getInferScalingListFlag() ) |
---|
| 307 | { |
---|
| 308 | // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive |
---|
| 309 | assert( pcPPS->getScalingListRefLayerId() <= 62 ); |
---|
| 310 | WRITE_CODE( pcPPS->getScalingListRefLayerId(), 6, "pps_scaling_list_ref_layer_id" ); |
---|
| 311 | } |
---|
[898] | 312 | |
---|
[1030] | 313 | WRITE_UVLC( pcPPS->getNumRefLayerLocationOffsets(), "num_ref_loc_offsets" ); |
---|
| 314 | for(Int k = 0; k < pcPPS->getNumRefLayerLocationOffsets(); k++) |
---|
[1029] | 315 | { |
---|
[1030] | 316 | WRITE_CODE( pcPPS->getRefLocationOffsetLayerId(k), 6, "ref_loc_offset_layer_id" ); |
---|
[1029] | 317 | WRITE_FLAG( pcPPS->getScaledRefLayerOffsetPresentFlag(k) ? 1 : 0, "scaled_ref_layer_offset_prsent_flag" ); |
---|
[1235] | 318 | if( pcPPS->getScaledRefLayerOffsetPresentFlag(k) ) |
---|
[1029] | 319 | { |
---|
| 320 | Window scaledWindow = pcPPS->getScaledRefLayerWindow(k); |
---|
| 321 | WRITE_SVLC( scaledWindow.getWindowLeftOffset() >> 1, "scaled_ref_layer_left_offset" ); |
---|
| 322 | WRITE_SVLC( scaledWindow.getWindowTopOffset() >> 1, "scaled_ref_layer_top_offset" ); |
---|
| 323 | WRITE_SVLC( scaledWindow.getWindowRightOffset() >> 1, "scaled_ref_layer_right_offset" ); |
---|
| 324 | WRITE_SVLC( scaledWindow.getWindowBottomOffset() >> 1, "scaled_ref_layer_bottom_offset" ); |
---|
| 325 | } |
---|
[1235] | 326 | |
---|
[1029] | 327 | WRITE_FLAG( pcPPS->getRefRegionOffsetPresentFlag(k) ? 1 : 0, "ref_region_offset_prsent_flag" ); |
---|
[1235] | 328 | |
---|
| 329 | if( pcPPS->getRefRegionOffsetPresentFlag(k) ) |
---|
[1029] | 330 | { |
---|
[1235] | 331 | const Window refWindow = pcPPS->getRefLayerWindow(k); |
---|
[1029] | 332 | WRITE_SVLC( refWindow.getWindowLeftOffset() >> 1, "ref_region_left_offset" ); |
---|
| 333 | WRITE_SVLC( refWindow.getWindowTopOffset() >> 1, "ref_region_top_offset" ); |
---|
| 334 | WRITE_SVLC( refWindow.getWindowRightOffset() >> 1, "ref_region_right_offset" ); |
---|
| 335 | WRITE_SVLC( refWindow.getWindowBottomOffset() >> 1, "ref_region_bottom_offset" ); |
---|
| 336 | } |
---|
[1235] | 337 | |
---|
[1029] | 338 | WRITE_FLAG( pcPPS->getResamplePhaseSetPresentFlag(k) ? 1 : 0, "resample_phase_set_present_flag" ); |
---|
[1235] | 339 | |
---|
| 340 | if( pcPPS->getResamplePhaseSetPresentFlag(k) ) |
---|
[1029] | 341 | { |
---|
| 342 | WRITE_UVLC( pcPPS->getPhaseHorLuma(k), "phase_hor_luma" ); |
---|
| 343 | WRITE_UVLC( pcPPS->getPhaseVerLuma(k), "phase_ver_luma" ); |
---|
| 344 | WRITE_UVLC( pcPPS->getPhaseHorChroma(k) + 8, "phase_hor_chroma_plus8" ); |
---|
| 345 | WRITE_UVLC( pcPPS->getPhaseVerChroma(k) + 8, "phase_ver_chroma_plus8" ); |
---|
| 346 | } |
---|
| 347 | } |
---|
[1212] | 348 | #if CGS_3D_ASYMLUT |
---|
[1029] | 349 | bits = getNumberOfWrittenBits(); |
---|
| 350 | WRITE_FLAG( pcPPS->getCGSFlag() , "colour_mapping_enabled_flag" ); |
---|
| 351 | if( pcPPS->getCGSFlag() ) |
---|
| 352 | { |
---|
| 353 | assert( pc3DAsymLUT != NULL ); |
---|
| 354 | xCode3DAsymLUT( pc3DAsymLUT ); |
---|
| 355 | } |
---|
| 356 | pc3DAsymLUT->setPPSBit( getNumberOfWrittenBits() - bits ); |
---|
[898] | 357 | #endif |
---|
[1029] | 358 | break; |
---|
[898] | 359 | #endif |
---|
[1029] | 360 | default: |
---|
| 361 | assert(pps_extension_flags[i]==false); // Should never get here with an active PPS extension flag. |
---|
| 362 | break; |
---|
| 363 | } // switch |
---|
| 364 | } // if flag present |
---|
| 365 | } // loop over PPS flags |
---|
| 366 | } // pps_extension_present_flag is non-zero |
---|
[313] | 367 | } |
---|
| 368 | |
---|
[1235] | 369 | Void TEncCavlc::codeVUI( const TComVUI *pcVUI, const TComSPS* pcSPS ) |
---|
[313] | 370 | { |
---|
| 371 | #if ENC_DEC_TRACE |
---|
| 372 | fprintf( g_hTrace, "----------- vui_parameters -----------\n"); |
---|
| 373 | #endif |
---|
| 374 | WRITE_FLAG(pcVUI->getAspectRatioInfoPresentFlag(), "aspect_ratio_info_present_flag"); |
---|
| 375 | if (pcVUI->getAspectRatioInfoPresentFlag()) |
---|
| 376 | { |
---|
| 377 | WRITE_CODE(pcVUI->getAspectRatioIdc(), 8, "aspect_ratio_idc" ); |
---|
| 378 | if (pcVUI->getAspectRatioIdc() == 255) |
---|
| 379 | { |
---|
| 380 | WRITE_CODE(pcVUI->getSarWidth(), 16, "sar_width"); |
---|
| 381 | WRITE_CODE(pcVUI->getSarHeight(), 16, "sar_height"); |
---|
| 382 | } |
---|
| 383 | } |
---|
| 384 | WRITE_FLAG(pcVUI->getOverscanInfoPresentFlag(), "overscan_info_present_flag"); |
---|
| 385 | if (pcVUI->getOverscanInfoPresentFlag()) |
---|
| 386 | { |
---|
| 387 | WRITE_FLAG(pcVUI->getOverscanAppropriateFlag(), "overscan_appropriate_flag"); |
---|
| 388 | } |
---|
| 389 | WRITE_FLAG(pcVUI->getVideoSignalTypePresentFlag(), "video_signal_type_present_flag"); |
---|
| 390 | if (pcVUI->getVideoSignalTypePresentFlag()) |
---|
| 391 | { |
---|
| 392 | WRITE_CODE(pcVUI->getVideoFormat(), 3, "video_format"); |
---|
| 393 | WRITE_FLAG(pcVUI->getVideoFullRangeFlag(), "video_full_range_flag"); |
---|
| 394 | WRITE_FLAG(pcVUI->getColourDescriptionPresentFlag(), "colour_description_present_flag"); |
---|
| 395 | if (pcVUI->getColourDescriptionPresentFlag()) |
---|
| 396 | { |
---|
| 397 | WRITE_CODE(pcVUI->getColourPrimaries(), 8, "colour_primaries"); |
---|
| 398 | WRITE_CODE(pcVUI->getTransferCharacteristics(), 8, "transfer_characteristics"); |
---|
| 399 | WRITE_CODE(pcVUI->getMatrixCoefficients(), 8, "matrix_coefficients"); |
---|
| 400 | } |
---|
| 401 | } |
---|
| 402 | |
---|
| 403 | WRITE_FLAG(pcVUI->getChromaLocInfoPresentFlag(), "chroma_loc_info_present_flag"); |
---|
| 404 | if (pcVUI->getChromaLocInfoPresentFlag()) |
---|
| 405 | { |
---|
| 406 | WRITE_UVLC(pcVUI->getChromaSampleLocTypeTopField(), "chroma_sample_loc_type_top_field"); |
---|
| 407 | WRITE_UVLC(pcVUI->getChromaSampleLocTypeBottomField(), "chroma_sample_loc_type_bottom_field"); |
---|
| 408 | } |
---|
| 409 | |
---|
| 410 | WRITE_FLAG(pcVUI->getNeutralChromaIndicationFlag(), "neutral_chroma_indication_flag"); |
---|
| 411 | WRITE_FLAG(pcVUI->getFieldSeqFlag(), "field_seq_flag"); |
---|
| 412 | WRITE_FLAG(pcVUI->getFrameFieldInfoPresentFlag(), "frame_field_info_present_flag"); |
---|
| 413 | |
---|
| 414 | Window defaultDisplayWindow = pcVUI->getDefaultDisplayWindow(); |
---|
| 415 | WRITE_FLAG(defaultDisplayWindow.getWindowEnabledFlag(), "default_display_window_flag"); |
---|
| 416 | if( defaultDisplayWindow.getWindowEnabledFlag() ) |
---|
| 417 | { |
---|
[823] | 418 | WRITE_UVLC(defaultDisplayWindow.getWindowLeftOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc()), "def_disp_win_left_offset"); |
---|
| 419 | WRITE_UVLC(defaultDisplayWindow.getWindowRightOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc()), "def_disp_win_right_offset"); |
---|
| 420 | WRITE_UVLC(defaultDisplayWindow.getWindowTopOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc()), "def_disp_win_top_offset"); |
---|
| 421 | WRITE_UVLC(defaultDisplayWindow.getWindowBottomOffset()/ TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc()), "def_disp_win_bottom_offset"); |
---|
[313] | 422 | } |
---|
[1235] | 423 | const TimingInfo *timingInfo = pcVUI->getTimingInfo(); |
---|
[313] | 424 | WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(), "vui_timing_info_present_flag"); |
---|
| 425 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
| 426 | { |
---|
| 427 | WRITE_CODE(timingInfo->getNumUnitsInTick(), 32, "vui_num_units_in_tick"); |
---|
| 428 | WRITE_CODE(timingInfo->getTimeScale(), 32, "vui_time_scale"); |
---|
| 429 | WRITE_FLAG(timingInfo->getPocProportionalToTimingFlag(), "vui_poc_proportional_to_timing_flag"); |
---|
| 430 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
| 431 | { |
---|
| 432 | WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(), "vui_num_ticks_poc_diff_one_minus1"); |
---|
| 433 | } |
---|
[1029] | 434 | WRITE_FLAG(pcVUI->getHrdParametersPresentFlag(), "hrd_parameters_present_flag"); |
---|
| 435 | if( pcVUI->getHrdParametersPresentFlag() ) |
---|
| 436 | { |
---|
| 437 | codeHrdParameters(pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); |
---|
| 438 | } |
---|
[313] | 439 | } |
---|
| 440 | |
---|
| 441 | WRITE_FLAG(pcVUI->getBitstreamRestrictionFlag(), "bitstream_restriction_flag"); |
---|
| 442 | if (pcVUI->getBitstreamRestrictionFlag()) |
---|
| 443 | { |
---|
| 444 | WRITE_FLAG(pcVUI->getTilesFixedStructureFlag(), "tiles_fixed_structure_flag"); |
---|
| 445 | WRITE_FLAG(pcVUI->getMotionVectorsOverPicBoundariesFlag(), "motion_vectors_over_pic_boundaries_flag"); |
---|
| 446 | WRITE_FLAG(pcVUI->getRestrictedRefPicListsFlag(), "restricted_ref_pic_lists_flag"); |
---|
| 447 | WRITE_UVLC(pcVUI->getMinSpatialSegmentationIdc(), "min_spatial_segmentation_idc"); |
---|
| 448 | WRITE_UVLC(pcVUI->getMaxBytesPerPicDenom(), "max_bytes_per_pic_denom"); |
---|
| 449 | WRITE_UVLC(pcVUI->getMaxBitsPerMinCuDenom(), "max_bits_per_mincu_denom"); |
---|
| 450 | WRITE_UVLC(pcVUI->getLog2MaxMvLengthHorizontal(), "log2_max_mv_length_horizontal"); |
---|
| 451 | WRITE_UVLC(pcVUI->getLog2MaxMvLengthVertical(), "log2_max_mv_length_vertical"); |
---|
| 452 | } |
---|
| 453 | } |
---|
| 454 | |
---|
[1235] | 455 | Void TEncCavlc::codeHrdParameters( const TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 ) |
---|
[313] | 456 | { |
---|
| 457 | if( commonInfPresentFlag ) |
---|
| 458 | { |
---|
| 459 | WRITE_FLAG( hrd->getNalHrdParametersPresentFlag() ? 1 : 0 , "nal_hrd_parameters_present_flag" ); |
---|
| 460 | WRITE_FLAG( hrd->getVclHrdParametersPresentFlag() ? 1 : 0 , "vcl_hrd_parameters_present_flag" ); |
---|
| 461 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
| 462 | { |
---|
| 463 | WRITE_FLAG( hrd->getSubPicCpbParamsPresentFlag() ? 1 : 0, "sub_pic_cpb_params_present_flag" ); |
---|
| 464 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 465 | { |
---|
| 466 | WRITE_CODE( hrd->getTickDivisorMinus2(), 8, "tick_divisor_minus2" ); |
---|
| 467 | WRITE_CODE( hrd->getDuCpbRemovalDelayLengthMinus1(), 5, "du_cpb_removal_delay_length_minus1" ); |
---|
| 468 | WRITE_FLAG( hrd->getSubPicCpbParamsInPicTimingSEIFlag() ? 1 : 0, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); |
---|
| 469 | WRITE_CODE( hrd->getDpbOutputDelayDuLengthMinus1(), 5, "dpb_output_delay_du_length_minus1" ); |
---|
| 470 | } |
---|
| 471 | WRITE_CODE( hrd->getBitRateScale(), 4, "bit_rate_scale" ); |
---|
| 472 | WRITE_CODE( hrd->getCpbSizeScale(), 4, "cpb_size_scale" ); |
---|
| 473 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 474 | { |
---|
[1029] | 475 | WRITE_CODE( hrd->getDuCpbSizeScale(), 4, "du_cpb_size_scale" ); |
---|
[313] | 476 | } |
---|
| 477 | WRITE_CODE( hrd->getInitialCpbRemovalDelayLengthMinus1(), 5, "initial_cpb_removal_delay_length_minus1" ); |
---|
| 478 | WRITE_CODE( hrd->getCpbRemovalDelayLengthMinus1(), 5, "au_cpb_removal_delay_length_minus1" ); |
---|
| 479 | WRITE_CODE( hrd->getDpbOutputDelayLengthMinus1(), 5, "dpb_output_delay_length_minus1" ); |
---|
| 480 | } |
---|
| 481 | } |
---|
| 482 | Int i, j, nalOrVcl; |
---|
| 483 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
| 484 | { |
---|
| 485 | WRITE_FLAG( hrd->getFixedPicRateFlag( i ) ? 1 : 0, "fixed_pic_rate_general_flag"); |
---|
[1235] | 486 | Bool fixedPixRateWithinCvsFlag = true; |
---|
[313] | 487 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
| 488 | { |
---|
[1235] | 489 | fixedPixRateWithinCvsFlag = hrd->getFixedPicRateWithinCvsFlag( i ); |
---|
[313] | 490 | WRITE_FLAG( hrd->getFixedPicRateWithinCvsFlag( i ) ? 1 : 0, "fixed_pic_rate_within_cvs_flag"); |
---|
| 491 | } |
---|
[1235] | 492 | if( fixedPixRateWithinCvsFlag ) |
---|
[313] | 493 | { |
---|
| 494 | WRITE_UVLC( hrd->getPicDurationInTcMinus1( i ), "elemental_duration_in_tc_minus1"); |
---|
| 495 | } |
---|
| 496 | else |
---|
| 497 | { |
---|
| 498 | WRITE_FLAG( hrd->getLowDelayHrdFlag( i ) ? 1 : 0, "low_delay_hrd_flag"); |
---|
| 499 | } |
---|
| 500 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
| 501 | { |
---|
| 502 | WRITE_UVLC( hrd->getCpbCntMinus1( i ), "cpb_cnt_minus1"); |
---|
| 503 | } |
---|
[1029] | 504 | |
---|
[313] | 505 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
| 506 | { |
---|
| 507 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
| 508 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
| 509 | { |
---|
| 510 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
| 511 | { |
---|
| 512 | WRITE_UVLC( hrd->getBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_value_minus1"); |
---|
| 513 | WRITE_UVLC( hrd->getCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_value_minus1"); |
---|
| 514 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 515 | { |
---|
[1029] | 516 | WRITE_UVLC( hrd->getDuCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_du_value_minus1"); |
---|
[313] | 517 | WRITE_UVLC( hrd->getDuBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_du_value_minus1"); |
---|
| 518 | } |
---|
| 519 | WRITE_FLAG( hrd->getCbrFlag( i, j, nalOrVcl ) ? 1 : 0, "cbr_flag"); |
---|
| 520 | } |
---|
| 521 | } |
---|
| 522 | } |
---|
| 523 | } |
---|
| 524 | } |
---|
| 525 | |
---|
[1235] | 526 | Void TEncCavlc::codeSPS( const TComSPS* pcSPS ) |
---|
[313] | 527 | { |
---|
[1029] | 528 | #if SVC_EXTENSION |
---|
| 529 | Bool V1CompatibleSPSFlag = !(pcSPS->getLayerId() != 0 && pcSPS->getNumDirectRefLayers() != 0); |
---|
[898] | 530 | #endif |
---|
[1029] | 531 | |
---|
| 532 | const ChromaFormat format = pcSPS->getChromaFormatIdc(); |
---|
| 533 | const Bool chromaEnabled = isChromaEnabled(format); |
---|
| 534 | |
---|
| 535 | #if ENC_DEC_TRACE |
---|
[313] | 536 | xTraceSPSHeader (pcSPS); |
---|
| 537 | #endif |
---|
| 538 | WRITE_CODE( pcSPS->getVPSId (), 4, "sps_video_parameter_set_id" ); |
---|
[494] | 539 | #if SVC_EXTENSION |
---|
[313] | 540 | if(pcSPS->getLayerId() == 0) |
---|
| 541 | { |
---|
| 542 | #endif |
---|
[1029] | 543 | WRITE_CODE( pcSPS->getMaxTLayers() - 1, 3, "sps_max_sub_layers_minus1" ); |
---|
[898] | 544 | #if SVC_EXTENSION |
---|
| 545 | } |
---|
| 546 | else |
---|
| 547 | { |
---|
[1029] | 548 | WRITE_CODE( V1CompatibleSPSFlag ? (pcSPS->getMaxTLayers() - 1) : 7, 3, "sps_ext_or_max_sub_layers_minus1" ); |
---|
[898] | 549 | } |
---|
| 550 | |
---|
[1029] | 551 | if( V1CompatibleSPSFlag ) |
---|
[898] | 552 | { |
---|
| 553 | #endif |
---|
[1029] | 554 | WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0, "sps_temporal_id_nesting_flag" ); |
---|
| 555 | codePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
[494] | 556 | #if SVC_EXTENSION |
---|
[313] | 557 | } |
---|
| 558 | #endif |
---|
| 559 | WRITE_UVLC( pcSPS->getSPSId (), "sps_seq_parameter_set_id" ); |
---|
[1029] | 560 | #if SVC_EXTENSION |
---|
| 561 | if( !V1CompatibleSPSFlag ) |
---|
[313] | 562 | { |
---|
[442] | 563 | WRITE_FLAG( pcSPS->getUpdateRepFormatFlag(), "update_rep_format_flag" ); |
---|
[1029] | 564 | |
---|
| 565 | if( pcSPS->getUpdateRepFormatFlag()) |
---|
| 566 | { |
---|
| 567 | WRITE_CODE( pcSPS->getUpdateRepFormatIndex(), 8, "sps_rep_format_idx"); |
---|
| 568 | } |
---|
[313] | 569 | } |
---|
[1029] | 570 | else |
---|
[898] | 571 | { |
---|
| 572 | #endif |
---|
[1029] | 573 | WRITE_UVLC( Int(pcSPS->getChromaFormatIdc ()), "chroma_format_idc" ); |
---|
| 574 | if( format == CHROMA_444 ) |
---|
[898] | 575 | { |
---|
[1029] | 576 | WRITE_FLAG( 0, "separate_colour_plane_flag"); |
---|
[442] | 577 | } |
---|
[313] | 578 | |
---|
[1029] | 579 | WRITE_UVLC( pcSPS->getPicWidthInLumaSamples (), "pic_width_in_luma_samples" ); |
---|
| 580 | WRITE_UVLC( pcSPS->getPicHeightInLumaSamples(), "pic_height_in_luma_samples" ); |
---|
| 581 | Window conf = pcSPS->getConformanceWindow(); |
---|
| 582 | |
---|
| 583 | WRITE_FLAG( conf.getWindowEnabledFlag(), "conformance_window_flag" ); |
---|
| 584 | if (conf.getWindowEnabledFlag()) |
---|
[313] | 585 | { |
---|
[1203] | 586 | #if SVC_EXTENSION |
---|
[1029] | 587 | WRITE_UVLC( conf.getWindowLeftOffset(), "conf_win_left_offset" ); |
---|
| 588 | WRITE_UVLC( conf.getWindowRightOffset(), "conf_win_right_offset" ); |
---|
| 589 | WRITE_UVLC( conf.getWindowTopOffset(), "conf_win_top_offset" ); |
---|
| 590 | WRITE_UVLC( conf.getWindowBottomOffset(), "conf_win_bottom_offset" ); |
---|
[713] | 591 | #else |
---|
[1029] | 592 | WRITE_UVLC( conf.getWindowLeftOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_left_offset" ); |
---|
| 593 | WRITE_UVLC( conf.getWindowRightOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_right_offset" ); |
---|
| 594 | WRITE_UVLC( conf.getWindowTopOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_top_offset" ); |
---|
| 595 | WRITE_UVLC( conf.getWindowBottomOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_bottom_offset" ); |
---|
[713] | 596 | #endif |
---|
[313] | 597 | } |
---|
[1029] | 598 | #if SVC_EXTENSION |
---|
| 599 | } |
---|
[313] | 600 | |
---|
[1029] | 601 | if( V1CompatibleSPSFlag ) |
---|
[442] | 602 | { |
---|
| 603 | #endif |
---|
[1029] | 604 | WRITE_UVLC( pcSPS->getBitDepth(CHANNEL_TYPE_LUMA) - 8, "bit_depth_luma_minus8" ); |
---|
| 605 | |
---|
| 606 | WRITE_UVLC( chromaEnabled ? (pcSPS->getBitDepth(CHANNEL_TYPE_CHROMA) - 8):0, "bit_depth_chroma_minus8" ); |
---|
| 607 | #if SVC_EXTENSION |
---|
[442] | 608 | } |
---|
| 609 | #endif |
---|
[898] | 610 | |
---|
[313] | 611 | WRITE_UVLC( pcSPS->getBitsForPOC()-4, "log2_max_pic_order_cnt_lsb_minus4" ); |
---|
| 612 | |
---|
[1029] | 613 | #if SVC_EXTENSION |
---|
| 614 | if( V1CompatibleSPSFlag ) |
---|
| 615 | { |
---|
[898] | 616 | #endif |
---|
[1029] | 617 | const Bool subLayerOrderingInfoPresentFlag = 1; |
---|
| 618 | WRITE_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); |
---|
| 619 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
[644] | 620 | { |
---|
[1029] | 621 | WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i) - 1, "sps_max_dec_pic_buffering_minus1[i]" ); |
---|
| 622 | WRITE_UVLC( pcSPS->getNumReorderPics(i), "sps_num_reorder_pics[i]" ); |
---|
| 623 | WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i), "sps_max_latency_increase_plus1[i]" ); |
---|
| 624 | if (!subLayerOrderingInfoPresentFlag) |
---|
[313] | 625 | { |
---|
[1029] | 626 | break; |
---|
[313] | 627 | } |
---|
[644] | 628 | } |
---|
[1029] | 629 | #if SVC_EXTENSION |
---|
| 630 | } |
---|
[644] | 631 | #endif |
---|
[313] | 632 | assert( pcSPS->getMaxCUWidth() == pcSPS->getMaxCUHeight() ); |
---|
[1029] | 633 | |
---|
[313] | 634 | WRITE_UVLC( pcSPS->getLog2MinCodingBlockSize() - 3, "log2_min_coding_block_size_minus3" ); |
---|
| 635 | WRITE_UVLC( pcSPS->getLog2DiffMaxMinCodingBlockSize(), "log2_diff_max_min_coding_block_size" ); |
---|
| 636 | WRITE_UVLC( pcSPS->getQuadtreeTULog2MinSize() - 2, "log2_min_transform_block_size_minus2" ); |
---|
| 637 | WRITE_UVLC( pcSPS->getQuadtreeTULog2MaxSize() - pcSPS->getQuadtreeTULog2MinSize(), "log2_diff_max_min_transform_block_size" ); |
---|
| 638 | WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthInter() - 1, "max_transform_hierarchy_depth_inter" ); |
---|
| 639 | WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthIntra() - 1, "max_transform_hierarchy_depth_intra" ); |
---|
[1029] | 640 | WRITE_FLAG( pcSPS->getScalingListFlag() ? 1 : 0, "scaling_list_enabled_flag" ); |
---|
[313] | 641 | if(pcSPS->getScalingListFlag()) |
---|
| 642 | { |
---|
[1223] | 643 | #if SVC_EXTENSION |
---|
[1029] | 644 | if( !V1CompatibleSPSFlag ) |
---|
[313] | 645 | { |
---|
[540] | 646 | WRITE_FLAG( pcSPS->getInferScalingListFlag() ? 1 : 0, "sps_infer_scaling_list_flag" ); |
---|
| 647 | } |
---|
[442] | 648 | |
---|
[540] | 649 | if( pcSPS->getInferScalingListFlag() ) |
---|
[442] | 650 | { |
---|
[540] | 651 | // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive |
---|
| 652 | assert( pcSPS->getScalingListRefLayerId() <= 62 ); |
---|
[442] | 653 | |
---|
[937] | 654 | WRITE_CODE( pcSPS->getScalingListRefLayerId(), 6, "sps_scaling_list_ref_layer_id" ); |
---|
[442] | 655 | } |
---|
| 656 | else |
---|
| 657 | { |
---|
[540] | 658 | #endif |
---|
[1029] | 659 | WRITE_FLAG( pcSPS->getScalingListPresentFlag() ? 1 : 0, "sps_scaling_list_data_present_flag" ); |
---|
| 660 | if(pcSPS->getScalingListPresentFlag()) |
---|
| 661 | { |
---|
[1235] | 662 | codeScalingList( pcSPS->getScalingList() ); |
---|
[1029] | 663 | } |
---|
[1223] | 664 | #if SVC_EXTENSION |
---|
[540] | 665 | } |
---|
[442] | 666 | #endif |
---|
[313] | 667 | } |
---|
| 668 | WRITE_FLAG( pcSPS->getUseAMP() ? 1 : 0, "amp_enabled_flag" ); |
---|
| 669 | WRITE_FLAG( pcSPS->getUseSAO() ? 1 : 0, "sample_adaptive_offset_enabled_flag"); |
---|
| 670 | |
---|
| 671 | WRITE_FLAG( pcSPS->getUsePCM() ? 1 : 0, "pcm_enabled_flag"); |
---|
| 672 | if( pcSPS->getUsePCM() ) |
---|
| 673 | { |
---|
[1029] | 674 | WRITE_CODE( pcSPS->getPCMBitDepth(CHANNEL_TYPE_LUMA) - 1, 4, "pcm_sample_bit_depth_luma_minus1" ); |
---|
| 675 | WRITE_CODE( chromaEnabled ? (pcSPS->getPCMBitDepth(CHANNEL_TYPE_CHROMA) - 1) : 0, 4, "pcm_sample_bit_depth_chroma_minus1" ); |
---|
[313] | 676 | WRITE_UVLC( pcSPS->getPCMLog2MinSize() - 3, "log2_min_pcm_luma_coding_block_size_minus3" ); |
---|
| 677 | WRITE_UVLC( pcSPS->getPCMLog2MaxSize() - pcSPS->getPCMLog2MinSize(), "log2_diff_max_min_pcm_luma_coding_block_size" ); |
---|
| 678 | WRITE_FLAG( pcSPS->getPCMFilterDisableFlag()?1 : 0, "pcm_loop_filter_disable_flag"); |
---|
| 679 | } |
---|
| 680 | |
---|
[1029] | 681 | assert( pcSPS->getMaxTLayers() > 0 ); |
---|
[313] | 682 | |
---|
[1235] | 683 | const TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
[1029] | 684 | |
---|
[313] | 685 | WRITE_UVLC(rpsList->getNumberOfReferencePictureSets(), "num_short_term_ref_pic_sets" ); |
---|
| 686 | for(Int i=0; i < rpsList->getNumberOfReferencePictureSets(); i++) |
---|
| 687 | { |
---|
[1235] | 688 | const TComReferencePictureSet*rps = rpsList->getReferencePictureSet(i); |
---|
| 689 | codeShortTermRefPicSet( rps,false, i); |
---|
[313] | 690 | } |
---|
| 691 | WRITE_FLAG( pcSPS->getLongTermRefsPresent() ? 1 : 0, "long_term_ref_pics_present_flag" ); |
---|
[1029] | 692 | if (pcSPS->getLongTermRefsPresent()) |
---|
[313] | 693 | { |
---|
| 694 | WRITE_UVLC(pcSPS->getNumLongTermRefPicSPS(), "num_long_term_ref_pic_sps" ); |
---|
| 695 | for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) |
---|
| 696 | { |
---|
| 697 | WRITE_CODE( pcSPS->getLtRefPicPocLsbSps(k), pcSPS->getBitsForPOC(), "lt_ref_pic_poc_lsb_sps"); |
---|
| 698 | WRITE_FLAG( pcSPS->getUsedByCurrPicLtSPSFlag(k), "used_by_curr_pic_lt_sps_flag"); |
---|
| 699 | } |
---|
| 700 | } |
---|
| 701 | WRITE_FLAG( pcSPS->getTMVPFlagsPresent() ? 1 : 0, "sps_temporal_mvp_enable_flag" ); |
---|
[595] | 702 | |
---|
[313] | 703 | WRITE_FLAG( pcSPS->getUseStrongIntraSmoothing(), "sps_strong_intra_smoothing_enable_flag" ); |
---|
| 704 | |
---|
| 705 | WRITE_FLAG( pcSPS->getVuiParametersPresentFlag(), "vui_parameters_present_flag" ); |
---|
| 706 | if (pcSPS->getVuiParametersPresentFlag()) |
---|
| 707 | { |
---|
| 708 | codeVUI(pcSPS->getVuiParameters(), pcSPS); |
---|
| 709 | } |
---|
| 710 | |
---|
[1029] | 711 | Bool sps_extension_present_flag=false; |
---|
| 712 | Bool sps_extension_flags[NUM_SPS_EXTENSION_FLAGS]={false}; |
---|
| 713 | |
---|
| 714 | sps_extension_flags[SPS_EXT__REXT] = ( |
---|
| 715 | pcSPS->getUseResidualRotation() |
---|
| 716 | || pcSPS->getUseSingleSignificanceMapContext() |
---|
| 717 | || pcSPS->getUseResidualDPCM(RDPCM_SIGNAL_IMPLICIT) |
---|
| 718 | || pcSPS->getUseResidualDPCM(RDPCM_SIGNAL_EXPLICIT) |
---|
| 719 | || pcSPS->getUseExtendedPrecision() |
---|
| 720 | || pcSPS->getDisableIntraReferenceSmoothing() |
---|
| 721 | || pcSPS->getUseHighPrecisionPredictionWeighting() |
---|
| 722 | || pcSPS->getUseGolombRiceParameterAdaptation() |
---|
| 723 | || pcSPS->getAlignCABACBeforeBypass() |
---|
| 724 | ); |
---|
| 725 | |
---|
| 726 | // Other SPS extension flags checked here. |
---|
[815] | 727 | #if SVC_EXTENSION |
---|
[1029] | 728 | sps_extension_flags[SPS_EXT__MLAYER] = pcSPS->getExtensionFlag() ? 1 : 0; |
---|
[898] | 729 | #endif |
---|
[815] | 730 | |
---|
[1029] | 731 | for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) |
---|
[313] | 732 | { |
---|
[1029] | 733 | sps_extension_present_flag|=sps_extension_flags[i]; |
---|
| 734 | } |
---|
| 735 | |
---|
| 736 | WRITE_FLAG( (sps_extension_present_flag?1:0), "sps_extension_present_flag" ); |
---|
| 737 | |
---|
| 738 | if (sps_extension_present_flag) |
---|
| 739 | { |
---|
| 740 | for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) |
---|
[540] | 741 | { |
---|
[1029] | 742 | WRITE_FLAG( sps_extension_flags[i]?1:0, "sps_extension_flag[]" ); |
---|
[540] | 743 | } |
---|
[1029] | 744 | |
---|
| 745 | for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. |
---|
[540] | 746 | { |
---|
[1029] | 747 | if (sps_extension_flags[i]) |
---|
| 748 | { |
---|
| 749 | switch (SPSExtensionFlagIndex(i)) |
---|
| 750 | { |
---|
| 751 | case SPS_EXT__REXT: |
---|
[815] | 752 | |
---|
[1029] | 753 | WRITE_FLAG( (pcSPS->getUseResidualRotation() ? 1 : 0), "transform_skip_rotation_enabled_flag"); |
---|
| 754 | WRITE_FLAG( (pcSPS->getUseSingleSignificanceMapContext() ? 1 : 0), "transform_skip_context_enabled_flag"); |
---|
| 755 | WRITE_FLAG( (pcSPS->getUseResidualDPCM(RDPCM_SIGNAL_IMPLICIT) ? 1 : 0), "residual_dpcm_implicit_enabled_flag" ); |
---|
| 756 | WRITE_FLAG( (pcSPS->getUseResidualDPCM(RDPCM_SIGNAL_EXPLICIT) ? 1 : 0), "residual_dpcm_explicit_enabled_flag" ); |
---|
| 757 | WRITE_FLAG( (pcSPS->getUseExtendedPrecision() ? 1 : 0), "extended_precision_processing_flag" ); |
---|
| 758 | WRITE_FLAG( (pcSPS->getDisableIntraReferenceSmoothing() ? 1 : 0), "intra_smoothing_disabled_flag" ); |
---|
| 759 | WRITE_FLAG( (pcSPS->getUseHighPrecisionPredictionWeighting() ? 1 : 0), "high_precision_prediction_weighting_flag" ); |
---|
| 760 | WRITE_FLAG( (pcSPS->getUseGolombRiceParameterAdaptation() ? 1 : 0), "golomb_rice_parameter_adaptation_flag" ); |
---|
| 761 | WRITE_FLAG( (pcSPS->getAlignCABACBeforeBypass() ? 1 : 0), "cabac_bypass_alignment_enabled_flag" ); |
---|
| 762 | break; |
---|
[815] | 763 | #if SVC_EXTENSION |
---|
[1029] | 764 | case SPS_EXT__MLAYER: |
---|
| 765 | codeSPSExtension( pcSPS ); //it is sps_multilayer_extension |
---|
| 766 | break; |
---|
[540] | 767 | #endif |
---|
[1029] | 768 | default: |
---|
| 769 | assert(sps_extension_flags[i]==false); // Should never get here with an active SPS extension flag. |
---|
| 770 | break; |
---|
| 771 | } |
---|
| 772 | } |
---|
[313] | 773 | } |
---|
| 774 | } |
---|
| 775 | } |
---|
[815] | 776 | |
---|
[1235] | 777 | Void TEncCavlc::codeVPS( const TComVPS* pcVPS ) |
---|
[313] | 778 | { |
---|
| 779 | WRITE_CODE( pcVPS->getVPSId(), 4, "vps_video_parameter_set_id" ); |
---|
[1180] | 780 | #if SVC_EXTENSION |
---|
[836] | 781 | WRITE_FLAG( pcVPS->getBaseLayerInternalFlag(), "vps_base_layer_internal_flag"); |
---|
| 782 | WRITE_FLAG( pcVPS->getBaseLayerAvailableFlag(), "vps_base_layer_available_flag"); |
---|
[954] | 783 | WRITE_CODE( pcVPS->getMaxLayers() - 1, 6, "vps_max_layers_minus1" ); |
---|
[1029] | 784 | assert( pcVPS->getBaseLayerInternalFlag() || pcVPS->getMaxLayers() > 1 ); |
---|
[313] | 785 | #else |
---|
[1180] | 786 | WRITE_CODE( 3, 2, "vps_reserved_three_2bits" ); |
---|
[1237] | 787 | WRITE_CODE( 0, 6, "vps_max_layers_minus1" ); |
---|
[313] | 788 | #endif |
---|
| 789 | WRITE_CODE( pcVPS->getMaxTLayers() - 1, 3, "vps_max_sub_layers_minus1" ); |
---|
| 790 | WRITE_FLAG( pcVPS->getTemporalNestingFlag(), "vps_temporal_id_nesting_flag" ); |
---|
| 791 | assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); |
---|
| 792 | WRITE_CODE( 0xffff, 16, "vps_reserved_ffff_16bits" ); |
---|
| 793 | codePTL( pcVPS->getPTL(), true, pcVPS->getMaxTLayers() - 1 ); |
---|
| 794 | const Bool subLayerOrderingInfoPresentFlag = 1; |
---|
| 795 | WRITE_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); |
---|
| 796 | for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
| 797 | { |
---|
| 798 | WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i) - 1, "vps_max_dec_pic_buffering_minus1[i]" ); |
---|
| 799 | WRITE_UVLC( pcVPS->getNumReorderPics(i), "vps_num_reorder_pics[i]" ); |
---|
| 800 | WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i), "vps_max_latency_increase_plus1[i]" ); |
---|
| 801 | if (!subLayerOrderingInfoPresentFlag) |
---|
| 802 | { |
---|
| 803 | break; |
---|
| 804 | } |
---|
| 805 | } |
---|
| 806 | |
---|
[815] | 807 | #if SVC_EXTENSION |
---|
[313] | 808 | assert( pcVPS->getNumHrdParameters() <= MAX_VPS_LAYER_SETS_PLUS1 ); |
---|
[1048] | 809 | assert( pcVPS->getMaxLayerId() < MAX_VPS_LAYER_IDX_PLUS1 ); |
---|
[1171] | 810 | |
---|
[313] | 811 | WRITE_CODE( pcVPS->getMaxLayerId(), 6, "vps_max_layer_id" ); |
---|
[815] | 812 | WRITE_UVLC(pcVPS->getVpsNumLayerSetsMinus1(), "vps_num_layer_sets_minus1"); |
---|
[1172] | 813 | |
---|
| 814 | for( UInt opsIdx = 1; opsIdx <= pcVPS->getVpsNumLayerSetsMinus1(); opsIdx++ ) |
---|
[313] | 815 | { |
---|
| 816 | // Operation point set |
---|
| 817 | for( UInt i = 0; i <= pcVPS->getMaxLayerId(); i ++ ) |
---|
[1171] | 818 | { |
---|
[313] | 819 | #else |
---|
| 820 | assert( pcVPS->getNumHrdParameters() <= MAX_VPS_NUM_HRD_PARAMETERS ); |
---|
| 821 | assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); |
---|
| 822 | WRITE_CODE( pcVPS->getMaxNuhReservedZeroLayerId(), 6, "vps_max_nuh_reserved_zero_layer_id" ); |
---|
| 823 | WRITE_UVLC( pcVPS->getMaxOpSets() - 1, "vps_max_op_sets_minus1" ); |
---|
| 824 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) |
---|
| 825 | { |
---|
| 826 | // Operation point set |
---|
| 827 | for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) |
---|
| 828 | { |
---|
| 829 | // Only applicable for version 1 |
---|
[1235] | 830 | // pcVPS->setLayerIdIncludedFlag( true, opsIdx, i ); |
---|
[313] | 831 | #endif |
---|
| 832 | WRITE_FLAG( pcVPS->getLayerIdIncludedFlag( opsIdx, i ) ? 1 : 0, "layer_id_included_flag[opsIdx][i]" ); |
---|
| 833 | } |
---|
| 834 | } |
---|
[1132] | 835 | |
---|
[1235] | 836 | const TimingInfo *timingInfo = pcVPS->getTimingInfo(); |
---|
[313] | 837 | WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(), "vps_timing_info_present_flag"); |
---|
| 838 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
| 839 | { |
---|
| 840 | WRITE_CODE(timingInfo->getNumUnitsInTick(), 32, "vps_num_units_in_tick"); |
---|
| 841 | WRITE_CODE(timingInfo->getTimeScale(), 32, "vps_time_scale"); |
---|
| 842 | WRITE_FLAG(timingInfo->getPocProportionalToTimingFlag(), "vps_poc_proportional_to_timing_flag"); |
---|
| 843 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
| 844 | { |
---|
| 845 | WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(), "vps_num_ticks_poc_diff_one_minus1"); |
---|
| 846 | } |
---|
| 847 | WRITE_UVLC( pcVPS->getNumHrdParameters(), "vps_num_hrd_parameters" ); |
---|
| 848 | |
---|
| 849 | if( pcVPS->getNumHrdParameters() > 0 ) |
---|
| 850 | { |
---|
[1235] | 851 | for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) |
---|
[313] | 852 | { |
---|
[1235] | 853 | // Only applicable for version 1 |
---|
| 854 | WRITE_UVLC( pcVPS->getHrdOpSetIdx( i ), "hrd_op_set_idx" ); |
---|
| 855 | if( i > 0 ) |
---|
| 856 | { |
---|
| 857 | WRITE_FLAG( pcVPS->getCprmsPresentFlag( i ) ? 1 : 0, "cprms_present_flag[i]" ); |
---|
| 858 | } |
---|
| 859 | codeHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); |
---|
[313] | 860 | } |
---|
| 861 | } |
---|
| 862 | } |
---|
[815] | 863 | #if SVC_EXTENSION |
---|
[713] | 864 | // When MaxLayersMinus1 is greater than 0, vps_extension_flag shall be equal to 1. |
---|
| 865 | if( pcVPS->getMaxLayers() > 1 ) |
---|
[442] | 866 | { |
---|
[713] | 867 | assert( pcVPS->getVpsExtensionFlag() == true ); |
---|
| 868 | } |
---|
| 869 | |
---|
| 870 | WRITE_FLAG( pcVPS->getVpsExtensionFlag() ? 1 : 0, "vps_extension_flag" ); |
---|
| 871 | |
---|
| 872 | if( pcVPS->getVpsExtensionFlag() ) |
---|
| 873 | { |
---|
[442] | 874 | while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) |
---|
| 875 | { |
---|
| 876 | WRITE_FLAG(1, "vps_extension_alignment_bit_equal_to_one"); |
---|
| 877 | } |
---|
| 878 | codeVPSExtension(pcVPS); |
---|
| 879 | WRITE_FLAG( 0, "vps_extension2_flag" ); // Flag value of 1 reserved |
---|
| 880 | } |
---|
[713] | 881 | #else |
---|
| 882 | WRITE_FLAG( 0, "vps_extension_flag" ); |
---|
[313] | 883 | #endif |
---|
| 884 | //future extensions here.. |
---|
| 885 | |
---|
| 886 | return; |
---|
| 887 | } |
---|
| 888 | |
---|
[1029] | 889 | Void TEncCavlc::codeSliceHeader ( TComSlice* pcSlice ) |
---|
| 890 | { |
---|
| 891 | #if ENC_DEC_TRACE |
---|
| 892 | xTraceSliceHeader (pcSlice); |
---|
| 893 | #endif |
---|
| 894 | |
---|
| 895 | const ChromaFormat format = pcSlice->getSPS()->getChromaFormatIdc(); |
---|
| 896 | const UInt numberValidComponents = getNumberValidComponents(format); |
---|
| 897 | const Bool chromaEnabled = isChromaEnabled(format); |
---|
| 898 | |
---|
| 899 | //calculate number of bits required for slice address |
---|
| 900 | Int maxSliceSegmentAddress = pcSlice->getPic()->getNumberOfCtusInFrame(); |
---|
| 901 | Int bitsSliceSegmentAddress = 0; |
---|
| 902 | while(maxSliceSegmentAddress>(1<<bitsSliceSegmentAddress)) |
---|
| 903 | { |
---|
| 904 | bitsSliceSegmentAddress++; |
---|
| 905 | } |
---|
| 906 | const Int ctuTsAddress = pcSlice->getSliceSegmentCurStartCtuTsAddr(); |
---|
| 907 | |
---|
| 908 | //write slice address |
---|
| 909 | const Int sliceSegmentRsAddress = pcSlice->getPic()->getPicSym()->getCtuTsToRsAddrMap(ctuTsAddress); |
---|
| 910 | |
---|
| 911 | WRITE_FLAG( sliceSegmentRsAddress==0, "first_slice_segment_in_pic_flag" ); |
---|
| 912 | if ( pcSlice->getRapPicFlag() ) |
---|
| 913 | { |
---|
| 914 | WRITE_FLAG( pcSlice->getNoOutputPriorPicsFlag() ? 1 : 0, "no_output_of_prior_pics_flag" ); |
---|
| 915 | } |
---|
| 916 | WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "slice_pic_parameter_set_id" ); |
---|
| 917 | if ( pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag() && (sliceSegmentRsAddress!=0) ) |
---|
| 918 | { |
---|
| 919 | WRITE_FLAG( pcSlice->getDependentSliceSegmentFlag() ? 1 : 0, "dependent_slice_segment_flag" ); |
---|
| 920 | } |
---|
| 921 | if(sliceSegmentRsAddress>0) |
---|
| 922 | { |
---|
| 923 | WRITE_CODE( sliceSegmentRsAddress, bitsSliceSegmentAddress, "slice_segment_address" ); |
---|
| 924 | } |
---|
| 925 | if ( !pcSlice->getDependentSliceSegmentFlag() ) |
---|
| 926 | { |
---|
[494] | 927 | #if SVC_EXTENSION |
---|
[1029] | 928 | Int iBits = 0; |
---|
| 929 | if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
---|
| 930 | { |
---|
| 931 | assert(!!"discardable_flag"); |
---|
[1183] | 932 | |
---|
[1029] | 933 | if (pcSlice->getDiscardableFlag()) |
---|
| 934 | { |
---|
| 935 | assert(pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R && |
---|
| 936 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R && |
---|
| 937 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R && |
---|
| 938 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R && |
---|
| 939 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R); |
---|
| 940 | } |
---|
[1183] | 941 | |
---|
[1029] | 942 | WRITE_FLAG(pcSlice->getDiscardableFlag(), "discardable_flag"); |
---|
| 943 | iBits++; |
---|
| 944 | } |
---|
[1108] | 945 | |
---|
[1029] | 946 | if( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits ) |
---|
| 947 | { |
---|
| 948 | assert(!!"cross_layer_bla_flag"); |
---|
| 949 | WRITE_FLAG(pcSlice->getCrossLayerBLAFlag(), "cross_layer_bla_flag"); |
---|
| 950 | iBits++; |
---|
| 951 | } |
---|
[1108] | 952 | |
---|
[1029] | 953 | for (; iBits < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) |
---|
| 954 | { |
---|
| 955 | assert(!!"slice_reserved_undetermined_flag[]"); |
---|
| 956 | WRITE_FLAG(0, "slice_reserved_undetermined_flag[]"); |
---|
| 957 | } |
---|
| 958 | #else //SVC_EXTENSION |
---|
| 959 | for (Int i = 0; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
| 960 | { |
---|
| 961 | assert(!!"slice_reserved_undetermined_flag[]"); |
---|
| 962 | WRITE_FLAG(0, "slice_reserved_undetermined_flag[]"); |
---|
| 963 | } |
---|
| 964 | #endif //SVC_EXTENSION |
---|
| 965 | |
---|
| 966 | WRITE_UVLC( pcSlice->getSliceType(), "slice_type" ); |
---|
| 967 | |
---|
| 968 | if( pcSlice->getPPS()->getOutputFlagPresentFlag() ) |
---|
| 969 | { |
---|
| 970 | WRITE_FLAG( pcSlice->getPicOutputFlag() ? 1 : 0, "pic_output_flag" ); |
---|
| 971 | } |
---|
| 972 | |
---|
[1187] | 973 | #if SVC_EXTENSION |
---|
[1043] | 974 | if( (pcSlice->getLayerId() > 0 && !pcSlice->getVPS()->getPocLsbNotPresentFlag( pcSlice->getVPS()->getLayerIdxInVps(pcSlice->getLayerId())) ) || !pcSlice->getIdrPicFlag()) |
---|
[1029] | 975 | #else |
---|
| 976 | if( !pcSlice->getIdrPicFlag() ) |
---|
| 977 | #endif |
---|
| 978 | { |
---|
[1209] | 979 | #if SVC_POC |
---|
[1029] | 980 | Int picOrderCntLSB; |
---|
| 981 | if( pcSlice->getPocResetIdc() == 2 ) // i.e. the LSB is reset |
---|
| 982 | { |
---|
| 983 | picOrderCntLSB = pcSlice->getPicOrderCntLsb(); // This will be the LSB value w.r.t to the previous POC reset period. |
---|
| 984 | } |
---|
| 985 | else |
---|
| 986 | { |
---|
| 987 | picOrderCntLSB = (pcSlice->getPOC() + (1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); |
---|
| 988 | } |
---|
| 989 | #else |
---|
| 990 | Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); |
---|
| 991 | #endif |
---|
| 992 | WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb"); |
---|
| 993 | |
---|
[1187] | 994 | #if SVC_EXTENSION |
---|
[1029] | 995 | } |
---|
[1101] | 996 | if( !pcSlice->getIdrPicFlag() ) |
---|
| 997 | { |
---|
[1029] | 998 | #endif |
---|
[1235] | 999 | const TComReferencePictureSet* rps = pcSlice->getRPS(); |
---|
[1029] | 1000 | |
---|
| 1001 | // check for bitstream restriction stating that: |
---|
| 1002 | // If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
| 1003 | // Ideally this process should not be repeated for each slice in a picture |
---|
| 1004 | #if SVC_EXTENSION |
---|
| 1005 | if( pcSlice->getLayerId() == 0 ) |
---|
| 1006 | #endif |
---|
| 1007 | if (pcSlice->isIRAP()) |
---|
| 1008 | { |
---|
| 1009 | for (Int picIdx = 0; picIdx < rps->getNumberOfPictures(); picIdx++) |
---|
| 1010 | { |
---|
| 1011 | assert (!rps->getUsed(picIdx)); |
---|
| 1012 | } |
---|
| 1013 | } |
---|
| 1014 | |
---|
| 1015 | if(pcSlice->getRPSidx() < 0) |
---|
| 1016 | { |
---|
| 1017 | WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag"); |
---|
[1235] | 1018 | codeShortTermRefPicSet( rps, true, pcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()); |
---|
[1029] | 1019 | } |
---|
| 1020 | else |
---|
| 1021 | { |
---|
| 1022 | WRITE_FLAG( 1, "short_term_ref_pic_set_sps_flag"); |
---|
| 1023 | Int numBits = 0; |
---|
| 1024 | while ((1 << numBits) < pcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
---|
| 1025 | { |
---|
| 1026 | numBits++; |
---|
| 1027 | } |
---|
| 1028 | if (numBits > 0) |
---|
| 1029 | { |
---|
| 1030 | WRITE_CODE( pcSlice->getRPSidx(), numBits, "short_term_ref_pic_set_idx" ); |
---|
| 1031 | } |
---|
| 1032 | } |
---|
| 1033 | if(pcSlice->getSPS()->getLongTermRefsPresent()) |
---|
| 1034 | { |
---|
| 1035 | Int numLtrpInSH = rps->getNumberOfLongtermPictures(); |
---|
| 1036 | Int ltrpInSPS[MAX_NUM_REF_PICS]; |
---|
| 1037 | Int numLtrpInSPS = 0; |
---|
| 1038 | UInt ltrpIndex; |
---|
| 1039 | Int counter = 0; |
---|
[1231] | 1040 | // WARNING: The following code only works only if a matching long-term RPS is |
---|
| 1041 | // found in the SPS for ALL long-term pictures |
---|
| 1042 | // The problem is that the SPS coded long-term pictures are moved to the |
---|
| 1043 | // beginning of the list which causes a mismatch when no reference picture |
---|
| 1044 | // list reordering is used |
---|
| 1045 | // NB: Long-term coding is currently not supported in general by the HM encoder |
---|
[1029] | 1046 | for(Int k = rps->getNumberOfPictures()-1; k > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; k--) |
---|
| 1047 | { |
---|
| 1048 | if (findMatchingLTRP(pcSlice, <rpIndex, rps->getPOC(k), rps->getUsed(k))) |
---|
| 1049 | { |
---|
| 1050 | ltrpInSPS[numLtrpInSPS] = ltrpIndex; |
---|
| 1051 | numLtrpInSPS++; |
---|
| 1052 | } |
---|
| 1053 | else |
---|
| 1054 | { |
---|
| 1055 | counter++; |
---|
| 1056 | } |
---|
| 1057 | } |
---|
| 1058 | numLtrpInSH -= numLtrpInSPS; |
---|
[1231] | 1059 | // check that either all long-term pictures are coded in SPS or in slice header (no mixing) |
---|
| 1060 | assert (numLtrpInSH==0 || numLtrpInSPS==0); |
---|
[1029] | 1061 | |
---|
| 1062 | Int bitsForLtrpInSPS = 0; |
---|
| 1063 | while (pcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
| 1064 | { |
---|
| 1065 | bitsForLtrpInSPS++; |
---|
| 1066 | } |
---|
| 1067 | if (pcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
---|
| 1068 | { |
---|
| 1069 | WRITE_UVLC( numLtrpInSPS, "num_long_term_sps"); |
---|
| 1070 | } |
---|
| 1071 | WRITE_UVLC( numLtrpInSH, "num_long_term_pics"); |
---|
| 1072 | // Note that the LSBs of the LT ref. pic. POCs must be sorted before. |
---|
| 1073 | // Not sorted here because LT ref indices will be used in setRefPicList() |
---|
| 1074 | Int prevDeltaMSB = 0, prevLSB = 0; |
---|
| 1075 | Int offset = rps->getNumberOfNegativePictures() + rps->getNumberOfPositivePictures(); |
---|
[1231] | 1076 | counter = 0; |
---|
| 1077 | // Warning: If some pictures are moved to ltrpInSPS, i is referring to a wrong index |
---|
| 1078 | // (mapping would be required) |
---|
| 1079 | for(Int i=rps->getNumberOfPictures()-1 ; i > offset-1; i--, counter++) |
---|
[1029] | 1080 | { |
---|
| 1081 | if (counter < numLtrpInSPS) |
---|
| 1082 | { |
---|
| 1083 | if (bitsForLtrpInSPS > 0) |
---|
| 1084 | { |
---|
| 1085 | WRITE_CODE( ltrpInSPS[counter], bitsForLtrpInSPS, "lt_idx_sps[i]"); |
---|
| 1086 | } |
---|
| 1087 | } |
---|
| 1088 | else |
---|
| 1089 | { |
---|
| 1090 | WRITE_CODE( rps->getPocLSBLT(i), pcSlice->getSPS()->getBitsForPOC(), "poc_lsb_lt"); |
---|
| 1091 | WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag"); |
---|
| 1092 | } |
---|
| 1093 | WRITE_FLAG( rps->getDeltaPocMSBPresentFlag(i), "delta_poc_msb_present_flag"); |
---|
| 1094 | |
---|
| 1095 | if(rps->getDeltaPocMSBPresentFlag(i)) |
---|
| 1096 | { |
---|
| 1097 | Bool deltaFlag = false; |
---|
| 1098 | // First LTRP from SPS || First LTRP from SH || curr LSB != prev LSB |
---|
| 1099 | if( (i == rps->getNumberOfPictures()-1) || (i == rps->getNumberOfPictures()-1-numLtrpInSPS) || (rps->getPocLSBLT(i) != prevLSB) ) |
---|
| 1100 | { |
---|
| 1101 | deltaFlag = true; |
---|
| 1102 | } |
---|
| 1103 | if(deltaFlag) |
---|
| 1104 | { |
---|
| 1105 | WRITE_UVLC( rps->getDeltaPocMSBCycleLT(i), "delta_poc_msb_cycle_lt[i]" ); |
---|
| 1106 | } |
---|
| 1107 | else |
---|
| 1108 | { |
---|
| 1109 | Int differenceInDeltaMSB = rps->getDeltaPocMSBCycleLT(i) - prevDeltaMSB; |
---|
| 1110 | assert(differenceInDeltaMSB >= 0); |
---|
| 1111 | WRITE_UVLC( differenceInDeltaMSB, "delta_poc_msb_cycle_lt[i]" ); |
---|
| 1112 | } |
---|
| 1113 | prevLSB = rps->getPocLSBLT(i); |
---|
| 1114 | prevDeltaMSB = rps->getDeltaPocMSBCycleLT(i); |
---|
| 1115 | } |
---|
| 1116 | } |
---|
| 1117 | } |
---|
| 1118 | if (pcSlice->getSPS()->getTMVPFlagsPresent()) |
---|
| 1119 | { |
---|
| 1120 | WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enabled_flag" ); |
---|
| 1121 | } |
---|
| 1122 | } |
---|
| 1123 | |
---|
| 1124 | #if SVC_EXTENSION |
---|
| 1125 | if((pcSlice->getLayerId() > 0) && !(pcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (pcSlice->getNumILRRefIdx() > 0) ) |
---|
| 1126 | { |
---|
| 1127 | WRITE_FLAG(pcSlice->getInterLayerPredEnabledFlag(),"inter_layer_pred_enabled_flag"); |
---|
| 1128 | if( pcSlice->getInterLayerPredEnabledFlag()) |
---|
| 1129 | { |
---|
| 1130 | if(pcSlice->getNumILRRefIdx() > 1) |
---|
| 1131 | { |
---|
| 1132 | Int numBits = 1; |
---|
| 1133 | while ((1 << numBits) < pcSlice->getNumILRRefIdx()) |
---|
| 1134 | { |
---|
| 1135 | numBits++; |
---|
| 1136 | } |
---|
| 1137 | if( !pcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) |
---|
| 1138 | { |
---|
| 1139 | WRITE_CODE(pcSlice->getActiveNumILRRefIdx() - 1, numBits,"num_inter_layer_ref_pics_minus1"); |
---|
| 1140 | } |
---|
| 1141 | |
---|
| 1142 | if( pcSlice->getNumILRRefIdx() != pcSlice->getActiveNumILRRefIdx() ) |
---|
| 1143 | { |
---|
| 1144 | for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
| 1145 | { |
---|
| 1146 | WRITE_CODE(pcSlice->getInterLayerPredLayerIdc(i),numBits,"inter_layer_pred_layer_idc[i]"); |
---|
| 1147 | } |
---|
| 1148 | } |
---|
| 1149 | } |
---|
| 1150 | } |
---|
| 1151 | } |
---|
| 1152 | #endif //SVC_EXTENSION |
---|
| 1153 | |
---|
| 1154 | if(pcSlice->getSPS()->getUseSAO()) |
---|
| 1155 | { |
---|
| 1156 | WRITE_FLAG( pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA), "slice_sao_luma_flag" ); |
---|
| 1157 | if (chromaEnabled) WRITE_FLAG( pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA), "slice_sao_chroma_flag" ); |
---|
| 1158 | } |
---|
| 1159 | |
---|
| 1160 | //check if numrefidxes match the defaults. If not, override |
---|
| 1161 | |
---|
| 1162 | if (!pcSlice->isIntra()) |
---|
| 1163 | { |
---|
| 1164 | Bool overrideFlag = (pcSlice->getNumRefIdx( REF_PIC_LIST_0 )!=pcSlice->getPPS()->getNumRefIdxL0DefaultActive()||(pcSlice->isInterB()&&pcSlice->getNumRefIdx( REF_PIC_LIST_1 )!=pcSlice->getPPS()->getNumRefIdxL1DefaultActive())); |
---|
| 1165 | WRITE_FLAG( overrideFlag ? 1 : 0, "num_ref_idx_active_override_flag"); |
---|
| 1166 | if (overrideFlag) |
---|
| 1167 | { |
---|
| 1168 | WRITE_UVLC( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - 1, "num_ref_idx_l0_active_minus1" ); |
---|
| 1169 | if (pcSlice->isInterB()) |
---|
| 1170 | { |
---|
| 1171 | WRITE_UVLC( pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - 1, "num_ref_idx_l1_active_minus1" ); |
---|
| 1172 | } |
---|
| 1173 | else |
---|
| 1174 | { |
---|
| 1175 | pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
| 1176 | } |
---|
| 1177 | } |
---|
| 1178 | } |
---|
| 1179 | else |
---|
| 1180 | { |
---|
| 1181 | pcSlice->setNumRefIdx(REF_PIC_LIST_0, 0); |
---|
| 1182 | pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
| 1183 | } |
---|
| 1184 | |
---|
| 1185 | if( pcSlice->getPPS()->getListsModificationPresentFlag() && pcSlice->getNumRpsCurrTempList() > 1) |
---|
| 1186 | { |
---|
| 1187 | TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); |
---|
| 1188 | if(!pcSlice->isIntra()) |
---|
| 1189 | { |
---|
| 1190 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0() ? 1 : 0, "ref_pic_list_modification_flag_l0" ); |
---|
| 1191 | if (pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0()) |
---|
| 1192 | { |
---|
| 1193 | Int numRpsCurrTempList0 = pcSlice->getNumRpsCurrTempList(); |
---|
| 1194 | if (numRpsCurrTempList0 > 1) |
---|
| 1195 | { |
---|
| 1196 | Int length = 1; |
---|
| 1197 | numRpsCurrTempList0 --; |
---|
| 1198 | while ( numRpsCurrTempList0 >>= 1) |
---|
| 1199 | { |
---|
| 1200 | length ++; |
---|
| 1201 | } |
---|
| 1202 | for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_0 ); i++) |
---|
| 1203 | { |
---|
| 1204 | WRITE_CODE( refPicListModification->getRefPicSetIdxL0(i), length, "list_entry_l0"); |
---|
| 1205 | } |
---|
| 1206 | } |
---|
| 1207 | } |
---|
| 1208 | } |
---|
| 1209 | if(pcSlice->isInterB()) |
---|
| 1210 | { |
---|
| 1211 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1() ? 1 : 0, "ref_pic_list_modification_flag_l1" ); |
---|
| 1212 | if (pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1()) |
---|
| 1213 | { |
---|
| 1214 | Int numRpsCurrTempList1 = pcSlice->getNumRpsCurrTempList(); |
---|
| 1215 | if ( numRpsCurrTempList1 > 1 ) |
---|
| 1216 | { |
---|
| 1217 | Int length = 1; |
---|
| 1218 | numRpsCurrTempList1 --; |
---|
| 1219 | while ( numRpsCurrTempList1 >>= 1) |
---|
| 1220 | { |
---|
| 1221 | length ++; |
---|
| 1222 | } |
---|
| 1223 | for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_1 ); i++) |
---|
| 1224 | { |
---|
| 1225 | WRITE_CODE( refPicListModification->getRefPicSetIdxL1(i), length, "list_entry_l1"); |
---|
| 1226 | } |
---|
| 1227 | } |
---|
| 1228 | } |
---|
| 1229 | } |
---|
| 1230 | } |
---|
| 1231 | |
---|
| 1232 | if (pcSlice->isInterB()) |
---|
| 1233 | { |
---|
| 1234 | WRITE_FLAG( pcSlice->getMvdL1ZeroFlag() ? 1 : 0, "mvd_l1_zero_flag"); |
---|
| 1235 | } |
---|
| 1236 | |
---|
| 1237 | if(!pcSlice->isIntra()) |
---|
| 1238 | { |
---|
| 1239 | if (!pcSlice->isIntra() && pcSlice->getPPS()->getCabacInitPresentFlag()) |
---|
| 1240 | { |
---|
| 1241 | SliceType sliceType = pcSlice->getSliceType(); |
---|
[1235] | 1242 | SliceType encCABACTableIdx = pcSlice->getEncCABACTableIdx(); |
---|
[1029] | 1243 | Bool encCabacInitFlag = (sliceType!=encCABACTableIdx && encCABACTableIdx!=I_SLICE) ? true : false; |
---|
| 1244 | pcSlice->setCabacInitFlag( encCabacInitFlag ); |
---|
| 1245 | WRITE_FLAG( encCabacInitFlag?1:0, "cabac_init_flag" ); |
---|
| 1246 | } |
---|
| 1247 | } |
---|
| 1248 | |
---|
| 1249 | if ( pcSlice->getEnableTMVPFlag() ) |
---|
| 1250 | { |
---|
| 1251 | if ( pcSlice->getSliceType() == B_SLICE ) |
---|
| 1252 | { |
---|
| 1253 | WRITE_FLAG( pcSlice->getColFromL0Flag(), "collocated_from_l0_flag" ); |
---|
| 1254 | } |
---|
| 1255 | |
---|
| 1256 | if ( pcSlice->getSliceType() != I_SLICE && |
---|
| 1257 | ((pcSlice->getColFromL0Flag()==1 && pcSlice->getNumRefIdx(REF_PIC_LIST_0)>1)|| |
---|
| 1258 | (pcSlice->getColFromL0Flag()==0 && pcSlice->getNumRefIdx(REF_PIC_LIST_1)>1))) |
---|
| 1259 | { |
---|
| 1260 | WRITE_UVLC( pcSlice->getColRefIdx(), "collocated_ref_idx" ); |
---|
| 1261 | } |
---|
| 1262 | } |
---|
| 1263 | if ( (pcSlice->getPPS()->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pcSlice->getPPS()->getWPBiPred() && pcSlice->getSliceType()==B_SLICE) ) |
---|
| 1264 | { |
---|
| 1265 | xCodePredWeightTable( pcSlice ); |
---|
| 1266 | } |
---|
| 1267 | assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS); |
---|
| 1268 | if (!pcSlice->isIntra()) |
---|
| 1269 | { |
---|
| 1270 | WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand"); |
---|
| 1271 | } |
---|
| 1272 | Int iCode = pcSlice->getSliceQp() - ( pcSlice->getPPS()->getPicInitQPMinus26() + 26 ); |
---|
| 1273 | WRITE_SVLC( iCode, "slice_qp_delta" ); |
---|
| 1274 | if (pcSlice->getPPS()->getSliceChromaQpFlag()) |
---|
| 1275 | { |
---|
| 1276 | if (numberValidComponents > COMPONENT_Cb) { WRITE_SVLC( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb), "slice_qp_delta_cb" ); } |
---|
| 1277 | if (numberValidComponents > COMPONENT_Cr) { WRITE_SVLC( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr), "slice_qp_delta_cr" ); } |
---|
| 1278 | assert(numberValidComponents <= COMPONENT_Cr+1); |
---|
| 1279 | } |
---|
| 1280 | |
---|
| 1281 | if (pcSlice->getPPS()->getChromaQpAdjTableSize() > 0) |
---|
| 1282 | { |
---|
| 1283 | WRITE_FLAG(pcSlice->getUseChromaQpAdj(), "slice_chroma_qp_adjustment_enabled_flag"); |
---|
| 1284 | } |
---|
| 1285 | |
---|
| 1286 | if (pcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
---|
| 1287 | { |
---|
| 1288 | if (pcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag() ) |
---|
| 1289 | { |
---|
| 1290 | WRITE_FLAG(pcSlice->getDeblockingFilterOverrideFlag(), "deblocking_filter_override_flag"); |
---|
| 1291 | } |
---|
| 1292 | if (pcSlice->getDeblockingFilterOverrideFlag()) |
---|
| 1293 | { |
---|
| 1294 | WRITE_FLAG(pcSlice->getDeblockingFilterDisable(), "slice_disable_deblocking_filter_flag"); |
---|
| 1295 | if(!pcSlice->getDeblockingFilterDisable()) |
---|
| 1296 | { |
---|
| 1297 | WRITE_SVLC (pcSlice->getDeblockingFilterBetaOffsetDiv2(), "slice_beta_offset_div2"); |
---|
| 1298 | WRITE_SVLC (pcSlice->getDeblockingFilterTcOffsetDiv2(), "slice_tc_offset_div2"); |
---|
| 1299 | } |
---|
| 1300 | } |
---|
| 1301 | } |
---|
| 1302 | |
---|
| 1303 | Bool isSAOEnabled = pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA) || (chromaEnabled && pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA))); |
---|
| 1304 | Bool isDBFEnabled = (!pcSlice->getDeblockingFilterDisable()); |
---|
| 1305 | |
---|
| 1306 | if(pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
| 1307 | { |
---|
| 1308 | WRITE_FLAG(pcSlice->getLFCrossSliceBoundaryFlag()?1:0, "slice_loop_filter_across_slices_enabled_flag"); |
---|
| 1309 | } |
---|
| 1310 | } |
---|
| 1311 | } |
---|
| 1312 | |
---|
[1235] | 1313 | Void TEncCavlc::codePTL( const TComPTL* pcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1) |
---|
[1029] | 1314 | { |
---|
| 1315 | if(profilePresentFlag) |
---|
| 1316 | { |
---|
| 1317 | codeProfileTier(pcPTL->getGeneralPTL()); // general_... |
---|
| 1318 | } |
---|
| 1319 | WRITE_CODE( Int(pcPTL->getGeneralPTL()->getLevelIdc()), 8, "general_level_idc" ); |
---|
| 1320 | |
---|
| 1321 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
| 1322 | { |
---|
[1182] | 1323 | #if SVC_EXTENSION |
---|
[1029] | 1324 | WRITE_FLAG( pcPTL->getSubLayerProfilePresentFlag(i), "sub_layer_profile_present_flag[i]" ); |
---|
| 1325 | #else |
---|
| 1326 | if(profilePresentFlag) |
---|
| 1327 | { |
---|
| 1328 | WRITE_FLAG( pcPTL->getSubLayerProfilePresentFlag(i), "sub_layer_profile_present_flag[i]" ); |
---|
| 1329 | } |
---|
| 1330 | #endif |
---|
| 1331 | |
---|
| 1332 | WRITE_FLAG( pcPTL->getSubLayerLevelPresentFlag(i), "sub_layer_level_present_flag[i]" ); |
---|
| 1333 | } |
---|
| 1334 | |
---|
| 1335 | if (maxNumSubLayersMinus1 > 0) |
---|
| 1336 | { |
---|
| 1337 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
| 1338 | { |
---|
| 1339 | WRITE_CODE(0, 2, "reserved_zero_2bits"); |
---|
| 1340 | } |
---|
| 1341 | } |
---|
| 1342 | |
---|
| 1343 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
| 1344 | { |
---|
[1182] | 1345 | #if SVC_EXTENSION |
---|
[1029] | 1346 | if( pcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
| 1347 | #else |
---|
| 1348 | if( profilePresentFlag && pcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
| 1349 | #endif |
---|
| 1350 | { |
---|
| 1351 | codeProfileTier(pcPTL->getSubLayerPTL(i)); // sub_layer_... |
---|
| 1352 | } |
---|
| 1353 | if( pcPTL->getSubLayerLevelPresentFlag(i) ) |
---|
| 1354 | { |
---|
| 1355 | WRITE_CODE( Int(pcPTL->getSubLayerPTL(i)->getLevelIdc()), 8, "sub_layer_level_idc[i]" ); |
---|
| 1356 | } |
---|
| 1357 | } |
---|
| 1358 | } |
---|
[1235] | 1359 | Void TEncCavlc::codeProfileTier( const ProfileTierLevel* ptl ) |
---|
[1029] | 1360 | { |
---|
| 1361 | WRITE_CODE( ptl->getProfileSpace(), 2 , "XXX_profile_space[]"); |
---|
| 1362 | WRITE_FLAG( ptl->getTierFlag()==Level::HIGH, "XXX_tier_flag[]" ); |
---|
[1182] | 1363 | #if SVC_EXTENSION |
---|
[1029] | 1364 | WRITE_CODE( (ptl->getProfileIdc() == Profile::SCALABLEMAIN || ptl->getProfileIdc() == Profile::SCALABLEMAIN10) ? 7 : Int(ptl->getProfileIdc()), 5 , "XXX_profile_idc[]" ); |
---|
| 1365 | #else |
---|
| 1366 | WRITE_CODE( Int(ptl->getProfileIdc()), 5 , "XXX_profile_idc[]" ); |
---|
| 1367 | #endif |
---|
| 1368 | for(Int j = 0; j < 32; j++) |
---|
| 1369 | { |
---|
| 1370 | WRITE_FLAG( ptl->getProfileCompatibilityFlag(j), "XXX_profile_compatibility_flag[][j]"); |
---|
| 1371 | } |
---|
| 1372 | |
---|
| 1373 | WRITE_FLAG(ptl->getProgressiveSourceFlag(), "general_progressive_source_flag"); |
---|
| 1374 | WRITE_FLAG(ptl->getInterlacedSourceFlag(), "general_interlaced_source_flag"); |
---|
| 1375 | WRITE_FLAG(ptl->getNonPackedConstraintFlag(), "general_non_packed_constraint_flag"); |
---|
| 1376 | WRITE_FLAG(ptl->getFrameOnlyConstraintFlag(), "general_frame_only_constraint_flag"); |
---|
| 1377 | |
---|
| 1378 | if (ptl->getProfileIdc() == Profile::MAINREXT || ptl->getProfileIdc() == Profile::HIGHTHROUGHPUTREXT ) |
---|
| 1379 | { |
---|
| 1380 | const UInt bitDepthConstraint=ptl->getBitDepthConstraint(); |
---|
| 1381 | WRITE_FLAG(bitDepthConstraint<=12, "general_max_12bit_constraint_flag"); |
---|
| 1382 | WRITE_FLAG(bitDepthConstraint<=10, "general_max_10bit_constraint_flag"); |
---|
| 1383 | WRITE_FLAG(bitDepthConstraint<= 8, "general_max_8bit_constraint_flag"); |
---|
| 1384 | const ChromaFormat chromaFmtConstraint=ptl->getChromaFormatConstraint(); |
---|
| 1385 | WRITE_FLAG(chromaFmtConstraint==CHROMA_422||chromaFmtConstraint==CHROMA_420||chromaFmtConstraint==CHROMA_400, "general_max_422chroma_constraint_flag"); |
---|
| 1386 | WRITE_FLAG(chromaFmtConstraint==CHROMA_420||chromaFmtConstraint==CHROMA_400, "general_max_420chroma_constraint_flag"); |
---|
| 1387 | WRITE_FLAG(chromaFmtConstraint==CHROMA_400, "general_max_monochrome_constraint_flag"); |
---|
| 1388 | WRITE_FLAG(ptl->getIntraConstraintFlag(), "general_intra_constraint_flag"); |
---|
| 1389 | WRITE_FLAG(0, "general_one_picture_only_constraint_flag"); |
---|
| 1390 | WRITE_FLAG(ptl->getLowerBitRateConstraintFlag(), "general_lower_bit_rate_constraint_flag"); |
---|
[1182] | 1391 | #if SVC_EXTENSION |
---|
[1029] | 1392 | WRITE_CODE(0, 32, "general_reserved_zero_34bits"); WRITE_CODE(0, 2, "general_reserved_zero_34bits"); |
---|
| 1393 | } |
---|
| 1394 | else if( ptl->getProfileIdc() == Profile::SCALABLEMAIN || ptl->getProfileIdc() == Profile::SCALABLEMAIN10 ) // at encoder side, scalable-main10 profile has a profile idc equal to 8, which is converted to 7 during signalling |
---|
| 1395 | { |
---|
| 1396 | WRITE_FLAG(true, "general_max_12bit_constraint_flag"); |
---|
| 1397 | WRITE_FLAG(true, "general_max_10bit_constraint_flag"); |
---|
| 1398 | WRITE_FLAG((ptl->getProfileIdc() == Profile::SCALABLEMAIN) ? true : false, "general_max_8bit_constraint_flag"); |
---|
| 1399 | WRITE_FLAG(true, "general_max_422chroma_constraint_flag"); |
---|
| 1400 | WRITE_FLAG(true, "general_max_420chroma_constraint_flag"); |
---|
| 1401 | WRITE_FLAG(false, "general_max_monochrome_constraint_flag"); |
---|
| 1402 | WRITE_FLAG(false, "general_intra_constraint_flag"); |
---|
| 1403 | WRITE_FLAG(false, "general_one_picture_only_constraint_flag"); |
---|
| 1404 | WRITE_FLAG(true, "general_lower_bit_rate_constraint_flag"); |
---|
| 1405 | WRITE_CODE(0, 32, "general_reserved_zero_34bits"); WRITE_CODE(0, 2, "general_reserved_zero_34bits"); |
---|
| 1406 | } |
---|
| 1407 | else |
---|
| 1408 | { |
---|
| 1409 | WRITE_CODE(0, 32, "general_reserved_zero_43bits"); WRITE_CODE(0, 11, "general_reserved_zero_43bits"); |
---|
| 1410 | } |
---|
| 1411 | |
---|
| 1412 | if( ( ptl->getProfileIdc() >= 1 && ptl->getProfileIdc() <= 5 ) || |
---|
| 1413 | ptl->getProfileCompatibilityFlag(1) || ptl->getProfileCompatibilityFlag(2) || |
---|
| 1414 | ptl->getProfileCompatibilityFlag(3) || ptl->getProfileCompatibilityFlag(4) || |
---|
| 1415 | ptl->getProfileCompatibilityFlag(5) ) |
---|
| 1416 | { |
---|
| 1417 | WRITE_FLAG(false, "general_inbld_flag"); |
---|
| 1418 | } |
---|
| 1419 | else |
---|
| 1420 | { |
---|
| 1421 | WRITE_FLAG(false, "general_reserved_zero_bit"); |
---|
| 1422 | } |
---|
| 1423 | #else |
---|
| 1424 | WRITE_CODE(0 , 16, "XXX_reserved_zero_35bits[0..15]"); |
---|
| 1425 | WRITE_CODE(0 , 16, "XXX_reserved_zero_35bits[16..31]"); |
---|
| 1426 | WRITE_CODE(0 , 3, "XXX_reserved_zero_35bits[32..34]"); |
---|
| 1427 | } |
---|
| 1428 | else |
---|
| 1429 | { |
---|
| 1430 | WRITE_CODE(0x0000 , 16, "XXX_reserved_zero_44bits[0..15]"); |
---|
| 1431 | WRITE_CODE(0x0000 , 16, "XXX_reserved_zero_44bits[16..31]"); |
---|
| 1432 | WRITE_CODE(0x000 , 12, "XXX_reserved_zero_44bits[32..43]"); |
---|
| 1433 | } |
---|
| 1434 | #endif |
---|
| 1435 | } |
---|
| 1436 | |
---|
| 1437 | /** |
---|
| 1438 | - write tiles and wavefront substreams sizes for the slice header. |
---|
| 1439 | . |
---|
| 1440 | \param pcSlice Where we find the substream size information. |
---|
| 1441 | */ |
---|
| 1442 | Void TEncCavlc::codeTilesWPPEntryPoint( TComSlice* pSlice ) |
---|
| 1443 | { |
---|
| 1444 | if (!pSlice->getPPS()->getTilesEnabledFlag() && !pSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) |
---|
| 1445 | { |
---|
| 1446 | return; |
---|
| 1447 | } |
---|
| 1448 | UInt maxOffset = 0; |
---|
| 1449 | for(Int idx=0; idx<pSlice->getNumberOfSubstreamSizes(); idx++) |
---|
| 1450 | { |
---|
| 1451 | UInt offset=pSlice->getSubstreamSize(idx); |
---|
| 1452 | if ( offset > maxOffset ) |
---|
| 1453 | { |
---|
| 1454 | maxOffset = offset; |
---|
| 1455 | } |
---|
| 1456 | } |
---|
| 1457 | |
---|
| 1458 | // Determine number of bits "offsetLenMinus1+1" required for entry point information |
---|
| 1459 | UInt offsetLenMinus1 = 0; |
---|
| 1460 | while (maxOffset >= (1u << (offsetLenMinus1 + 1))) |
---|
| 1461 | { |
---|
| 1462 | offsetLenMinus1++; |
---|
| 1463 | assert(offsetLenMinus1 + 1 < 32); |
---|
| 1464 | } |
---|
| 1465 | |
---|
| 1466 | WRITE_UVLC(pSlice->getNumberOfSubstreamSizes(), "num_entry_point_offsets"); |
---|
| 1467 | if (pSlice->getNumberOfSubstreamSizes()>0) |
---|
| 1468 | { |
---|
| 1469 | WRITE_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
| 1470 | |
---|
| 1471 | for (UInt idx=0; idx<pSlice->getNumberOfSubstreamSizes(); idx++) |
---|
| 1472 | { |
---|
| 1473 | WRITE_CODE(pSlice->getSubstreamSize(idx)-1, offsetLenMinus1+1, "entry_point_offset_minus1"); |
---|
| 1474 | } |
---|
| 1475 | } |
---|
| 1476 | } |
---|
| 1477 | |
---|
| 1478 | Void TEncCavlc::codeTerminatingBit ( UInt uilsLast ) |
---|
| 1479 | { |
---|
| 1480 | } |
---|
| 1481 | |
---|
| 1482 | Void TEncCavlc::codeSliceFinish () |
---|
| 1483 | { |
---|
| 1484 | } |
---|
| 1485 | |
---|
| 1486 | Void TEncCavlc::codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
| 1487 | { |
---|
| 1488 | assert(0); |
---|
| 1489 | } |
---|
| 1490 | |
---|
| 1491 | Void TEncCavlc::codePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1492 | { |
---|
| 1493 | assert(0); |
---|
| 1494 | } |
---|
| 1495 | |
---|
| 1496 | Void TEncCavlc::codePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1497 | { |
---|
| 1498 | assert(0); |
---|
| 1499 | } |
---|
| 1500 | |
---|
| 1501 | Void TEncCavlc::codeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1502 | { |
---|
| 1503 | assert(0); |
---|
| 1504 | } |
---|
| 1505 | |
---|
| 1506 | Void TEncCavlc::codeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1507 | { |
---|
| 1508 | assert(0); |
---|
| 1509 | } |
---|
| 1510 | |
---|
| 1511 | Void TEncCavlc::codeInterModeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiEncMode ) |
---|
| 1512 | { |
---|
| 1513 | assert(0); |
---|
| 1514 | } |
---|
| 1515 | |
---|
| 1516 | Void TEncCavlc::codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1517 | { |
---|
| 1518 | assert(0); |
---|
| 1519 | } |
---|
| 1520 | |
---|
| 1521 | Void TEncCavlc::codeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1522 | { |
---|
| 1523 | assert(0); |
---|
| 1524 | } |
---|
| 1525 | |
---|
| 1526 | Void TEncCavlc::codeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1527 | { |
---|
| 1528 | assert(0); |
---|
| 1529 | } |
---|
| 1530 | |
---|
| 1531 | Void TEncCavlc::codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) |
---|
| 1532 | { |
---|
| 1533 | assert(0); |
---|
| 1534 | } |
---|
| 1535 | |
---|
| 1536 | Void TEncCavlc::codeQtCbf( TComTU &rTu, const ComponentID compID, const Bool lowestLevel ) |
---|
| 1537 | { |
---|
| 1538 | assert(0); |
---|
| 1539 | } |
---|
| 1540 | |
---|
| 1541 | Void TEncCavlc::codeQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1542 | { |
---|
| 1543 | assert(0); |
---|
| 1544 | } |
---|
| 1545 | |
---|
| 1546 | Void TEncCavlc::codeQtCbfZero( TComTU &rTu, const ChannelType chType ) |
---|
| 1547 | { |
---|
| 1548 | assert(0); |
---|
| 1549 | } |
---|
| 1550 | Void TEncCavlc::codeQtRootCbfZero( TComDataCU* pcCU ) |
---|
| 1551 | { |
---|
| 1552 | assert(0); |
---|
| 1553 | } |
---|
| 1554 | |
---|
| 1555 | Void TEncCavlc::codeTransformSkipFlags (TComTU &rTu, ComponentID component ) |
---|
| 1556 | { |
---|
| 1557 | assert(0); |
---|
| 1558 | } |
---|
| 1559 | |
---|
| 1560 | /** Code I_PCM information. |
---|
| 1561 | * \param pcCU pointer to CU |
---|
| 1562 | * \param uiAbsPartIdx CU index |
---|
| 1563 | * \returns Void |
---|
| 1564 | */ |
---|
| 1565 | Void TEncCavlc::codeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1566 | { |
---|
| 1567 | assert(0); |
---|
| 1568 | } |
---|
| 1569 | |
---|
| 1570 | Void TEncCavlc::codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool isMultiple) |
---|
| 1571 | { |
---|
| 1572 | assert(0); |
---|
| 1573 | } |
---|
| 1574 | |
---|
| 1575 | Void TEncCavlc::codeIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1576 | { |
---|
| 1577 | assert(0); |
---|
| 1578 | } |
---|
| 1579 | |
---|
| 1580 | Void TEncCavlc::codeInterDir( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1581 | { |
---|
| 1582 | assert(0); |
---|
| 1583 | } |
---|
| 1584 | |
---|
| 1585 | Void TEncCavlc::codeRefFrmIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
| 1586 | { |
---|
| 1587 | assert(0); |
---|
| 1588 | } |
---|
| 1589 | |
---|
| 1590 | Void TEncCavlc::codeMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
| 1591 | { |
---|
| 1592 | assert(0); |
---|
| 1593 | } |
---|
| 1594 | |
---|
| 1595 | Void TEncCavlc::codeCrossComponentPrediction( TComTU& /*rTu*/, ComponentID /*compID*/ ) |
---|
| 1596 | { |
---|
| 1597 | assert(0); |
---|
| 1598 | } |
---|
| 1599 | |
---|
| 1600 | Void TEncCavlc::codeDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1601 | { |
---|
| 1602 | Int iDQp = pcCU->getQP( uiAbsPartIdx ) - pcCU->getRefQP( uiAbsPartIdx ); |
---|
| 1603 | |
---|
[1203] | 1604 | #if SVC_EXTENSION |
---|
[1029] | 1605 | Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffsetY(); |
---|
| 1606 | #else |
---|
| 1607 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA); |
---|
| 1608 | #endif |
---|
| 1609 | iDQp = (iDQp + 78 + qpBdOffsetY + (qpBdOffsetY/2)) % (52 + qpBdOffsetY) - 26 - (qpBdOffsetY/2); |
---|
| 1610 | |
---|
| 1611 | xWriteSvlc( iDQp ); |
---|
| 1612 | |
---|
| 1613 | return; |
---|
| 1614 | } |
---|
| 1615 | |
---|
| 1616 | Void TEncCavlc::codeChromaQpAdjustment( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1617 | { |
---|
| 1618 | assert(0); |
---|
| 1619 | } |
---|
| 1620 | |
---|
| 1621 | Void TEncCavlc::codeCoeffNxN ( TComTU &rTu, TCoeff* pcCoef, const ComponentID compID ) |
---|
| 1622 | { |
---|
| 1623 | assert(0); |
---|
| 1624 | } |
---|
| 1625 | |
---|
| 1626 | Void TEncCavlc::estBit( estBitsSbacStruct* pcEstBitsCabac, Int width, Int height, ChannelType chType ) |
---|
| 1627 | { |
---|
| 1628 | // printf("error : no VLC mode support in this version\n"); |
---|
| 1629 | return; |
---|
| 1630 | } |
---|
| 1631 | |
---|
| 1632 | // ==================================================================================================================== |
---|
| 1633 | // Protected member functions |
---|
| 1634 | // ==================================================================================================================== |
---|
| 1635 | |
---|
| 1636 | /** code explicit wp tables |
---|
| 1637 | * \param TComSlice* pcSlice |
---|
| 1638 | * \returns Void |
---|
| 1639 | */ |
---|
| 1640 | Void TEncCavlc::xCodePredWeightTable( TComSlice* pcSlice ) |
---|
| 1641 | { |
---|
| 1642 | WPScalingParam *wp; |
---|
| 1643 | const ChromaFormat format = pcSlice->getPic()->getChromaFormat(); |
---|
| 1644 | const UInt numberValidComponents = getNumberValidComponents(format); |
---|
| 1645 | const Bool bChroma = isChromaEnabled(format); |
---|
| 1646 | const Int iNbRef = (pcSlice->getSliceType() == B_SLICE ) ? (2) : (1); |
---|
| 1647 | Bool bDenomCoded = false; |
---|
| 1648 | UInt uiMode = 0; |
---|
| 1649 | UInt uiTotalSignalledWeightFlags = 0; |
---|
| 1650 | |
---|
| 1651 | if ( (pcSlice->getSliceType()==P_SLICE && pcSlice->getPPS()->getUseWP()) || (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPred()) ) |
---|
| 1652 | { |
---|
| 1653 | uiMode = 1; // explicit |
---|
| 1654 | } |
---|
| 1655 | if(uiMode == 1) |
---|
| 1656 | { |
---|
| 1657 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
| 1658 | { |
---|
| 1659 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
| 1660 | |
---|
| 1661 | // NOTE: wp[].uiLog2WeightDenom and wp[].bPresentFlag are actually per-channel-type settings. |
---|
| 1662 | |
---|
| 1663 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
| 1664 | { |
---|
| 1665 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 1666 | if ( !bDenomCoded ) |
---|
| 1667 | { |
---|
| 1668 | Int iDeltaDenom; |
---|
| 1669 | WRITE_UVLC( wp[COMPONENT_Y].uiLog2WeightDenom, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
| 1670 | |
---|
| 1671 | if( bChroma ) |
---|
| 1672 | { |
---|
| 1673 | assert(wp[COMPONENT_Cb].uiLog2WeightDenom == wp[COMPONENT_Cr].uiLog2WeightDenom); // check the channel-type settings are consistent across components. |
---|
| 1674 | iDeltaDenom = (wp[COMPONENT_Cb].uiLog2WeightDenom - wp[COMPONENT_Y].uiLog2WeightDenom); |
---|
| 1675 | WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
| 1676 | } |
---|
| 1677 | bDenomCoded = true; |
---|
| 1678 | } |
---|
| 1679 | WRITE_FLAG( wp[COMPONENT_Y].bPresentFlag, "luma_weight_lX_flag" ); // u(1): luma_weight_lX_flag |
---|
| 1680 | uiTotalSignalledWeightFlags += wp[COMPONENT_Y].bPresentFlag; |
---|
| 1681 | } |
---|
| 1682 | if (bChroma) |
---|
| 1683 | { |
---|
| 1684 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
| 1685 | { |
---|
| 1686 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 1687 | assert(wp[COMPONENT_Cb].bPresentFlag == wp[COMPONENT_Cr].bPresentFlag); // check the channel-type settings are consistent across components. |
---|
| 1688 | WRITE_FLAG( wp[COMPONENT_Cb].bPresentFlag, "chroma_weight_lX_flag" ); // u(1): chroma_weight_lX_flag |
---|
| 1689 | uiTotalSignalledWeightFlags += 2*wp[COMPONENT_Cb].bPresentFlag; |
---|
| 1690 | } |
---|
| 1691 | } |
---|
| 1692 | |
---|
| 1693 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
| 1694 | { |
---|
| 1695 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 1696 | if ( wp[COMPONENT_Y].bPresentFlag ) |
---|
| 1697 | { |
---|
| 1698 | Int iDeltaWeight = (wp[COMPONENT_Y].iWeight - (1<<wp[COMPONENT_Y].uiLog2WeightDenom)); |
---|
| 1699 | WRITE_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_lX |
---|
| 1700 | WRITE_SVLC( wp[COMPONENT_Y].iOffset, "luma_offset_lX" ); // se(v): luma_offset_lX |
---|
| 1701 | } |
---|
| 1702 | |
---|
| 1703 | if ( bChroma ) |
---|
| 1704 | { |
---|
| 1705 | if ( wp[COMPONENT_Cb].bPresentFlag ) |
---|
| 1706 | { |
---|
| 1707 | for ( Int j = COMPONENT_Cb ; j < numberValidComponents ; j++ ) |
---|
| 1708 | { |
---|
| 1709 | assert(wp[COMPONENT_Cb].uiLog2WeightDenom == wp[COMPONENT_Cr].uiLog2WeightDenom); |
---|
| 1710 | Int iDeltaWeight = (wp[j].iWeight - (1<<wp[COMPONENT_Cb].uiLog2WeightDenom)); |
---|
| 1711 | WRITE_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): delta_chroma_weight_lX |
---|
| 1712 | |
---|
| 1713 | Int range=pcSlice->getSPS()->getUseHighPrecisionPredictionWeighting() ? (1<<g_bitDepth[CHANNEL_TYPE_CHROMA])/2 : 128; |
---|
| 1714 | Int pred = ( range - ( ( range*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
| 1715 | Int iDeltaChroma = (wp[j].iOffset - pred); |
---|
| 1716 | WRITE_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_lX |
---|
| 1717 | } |
---|
| 1718 | } |
---|
| 1719 | } |
---|
| 1720 | } |
---|
| 1721 | } |
---|
| 1722 | assert(uiTotalSignalledWeightFlags<=24); |
---|
| 1723 | } |
---|
| 1724 | } |
---|
| 1725 | |
---|
| 1726 | /** code quantization matrix |
---|
| 1727 | * \param scalingList quantization matrix information |
---|
| 1728 | */ |
---|
[1235] | 1729 | Void TEncCavlc::codeScalingList( const TComScalingList &scalingList ) |
---|
[1029] | 1730 | { |
---|
| 1731 | //for each size |
---|
[1235] | 1732 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
[1029] | 1733 | { |
---|
[1235] | 1734 | const Int predListStep = (sizeId == SCALING_LIST_32x32? (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) : 1); // if 32x32, skip over chroma entries. |
---|
[1029] | 1735 | |
---|
[1235] | 1736 | for(UInt listId = 0; listId < SCALING_LIST_NUM; listId+=predListStep) |
---|
[1029] | 1737 | { |
---|
[1235] | 1738 | Bool scalingListPredModeFlag = scalingList.getScalingListPredModeFlag(sizeId, listId); |
---|
[1029] | 1739 | WRITE_FLAG( scalingListPredModeFlag, "scaling_list_pred_mode_flag" ); |
---|
| 1740 | if(!scalingListPredModeFlag)// Copy Mode |
---|
| 1741 | { |
---|
| 1742 | if (sizeId == SCALING_LIST_32x32) |
---|
| 1743 | { |
---|
| 1744 | // adjust the code, to cope with the missing chroma entries |
---|
[1235] | 1745 | WRITE_UVLC( ((Int)listId - (Int)scalingList.getRefMatrixId (sizeId,listId)) / (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES), "scaling_list_pred_matrix_id_delta"); |
---|
[1029] | 1746 | } |
---|
| 1747 | else |
---|
| 1748 | { |
---|
[1235] | 1749 | WRITE_UVLC( (Int)listId - (Int)scalingList.getRefMatrixId (sizeId,listId), "scaling_list_pred_matrix_id_delta"); |
---|
[1029] | 1750 | } |
---|
| 1751 | } |
---|
| 1752 | else// DPCM Mode |
---|
| 1753 | { |
---|
[1235] | 1754 | xCodeScalingList(&scalingList, sizeId, listId); |
---|
[1029] | 1755 | } |
---|
| 1756 | } |
---|
| 1757 | } |
---|
| 1758 | return; |
---|
| 1759 | } |
---|
| 1760 | /** code DPCM |
---|
| 1761 | * \param scalingList quantization matrix information |
---|
| 1762 | * \param sizeIdc size index |
---|
| 1763 | * \param listIdc list index |
---|
| 1764 | */ |
---|
[1235] | 1765 | Void TEncCavlc::xCodeScalingList(const TComScalingList* scalingList, UInt sizeId, UInt listId) |
---|
[1029] | 1766 | { |
---|
| 1767 | Int coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
| 1768 | UInt* scan = g_scanOrder[SCAN_UNGROUPED][SCAN_DIAG][sizeId==0 ? 2 : 3][sizeId==0 ? 2 : 3]; |
---|
| 1769 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
| 1770 | Int data; |
---|
[1235] | 1771 | const Int *src = scalingList->getScalingListAddress(sizeId, listId); |
---|
[1029] | 1772 | if( sizeId > SCALING_LIST_8x8 ) |
---|
| 1773 | { |
---|
| 1774 | WRITE_SVLC( scalingList->getScalingListDC(sizeId,listId) - 8, "scaling_list_dc_coef_minus8"); |
---|
| 1775 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
| 1776 | } |
---|
| 1777 | for(Int i=0;i<coefNum;i++) |
---|
| 1778 | { |
---|
| 1779 | data = src[scan[i]] - nextCoef; |
---|
| 1780 | nextCoef = src[scan[i]]; |
---|
| 1781 | if(data > 127) |
---|
| 1782 | { |
---|
| 1783 | data = data - 256; |
---|
| 1784 | } |
---|
| 1785 | if(data < -128) |
---|
| 1786 | { |
---|
| 1787 | data = data + 256; |
---|
| 1788 | } |
---|
| 1789 | |
---|
| 1790 | WRITE_SVLC( data, "scaling_list_delta_coef"); |
---|
| 1791 | } |
---|
| 1792 | } |
---|
| 1793 | Bool TEncCavlc::findMatchingLTRP ( TComSlice* pcSlice, UInt *ltrpsIndex, Int ltrpPOC, Bool usedFlag ) |
---|
| 1794 | { |
---|
| 1795 | // Bool state = true, state2 = false; |
---|
| 1796 | Int lsb = ltrpPOC & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); |
---|
| 1797 | for (Int k = 0; k < pcSlice->getSPS()->getNumLongTermRefPicSPS(); k++) |
---|
| 1798 | { |
---|
| 1799 | if ( (lsb == pcSlice->getSPS()->getLtRefPicPocLsbSps(k)) && (usedFlag == pcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(k)) ) |
---|
| 1800 | { |
---|
| 1801 | *ltrpsIndex = k; |
---|
| 1802 | return true; |
---|
| 1803 | } |
---|
| 1804 | } |
---|
| 1805 | return false; |
---|
| 1806 | } |
---|
| 1807 | |
---|
| 1808 | Void TEncCavlc::codeExplicitRdpcmMode( TComTU &rTu, const ComponentID compID ) |
---|
| 1809 | { |
---|
| 1810 | assert(0); |
---|
| 1811 | } |
---|
| 1812 | |
---|
| 1813 | #if SVC_EXTENSION |
---|
[1207] | 1814 | Void TEncCavlc::codeSliceHeaderExtn( TComSlice* slice, Int shBitsWrittenTillNow ) |
---|
[1029] | 1815 | { |
---|
| 1816 | Int tmpBitsBeforeWriting = getNumberOfWrittenBits(); |
---|
| 1817 | Int maxPocLsb = 1 << slice->getSPS()->getBitsForPOC(); |
---|
| 1818 | if(slice->getPPS()->getSliceHeaderExtensionPresentFlag()) |
---|
| 1819 | { |
---|
| 1820 | // Derive the value of PocMsbValRequiredFlag |
---|
| 1821 | slice->setPocMsbValRequiredFlag( (slice->getCraPicFlag() || slice->getBlaPicFlag()) |
---|
| 1822 | && (!slice->getVPS()->getVpsPocLsbAlignedFlag() || |
---|
| 1823 | (slice->getVPS()->getVpsPocLsbAlignedFlag() && slice->getVPS()->getNumDirectRefLayers(slice->getLayerId()) == 0)) |
---|
| 1824 | ); |
---|
| 1825 | |
---|
| 1826 | // Determine value of SH extension length. |
---|
| 1827 | Int shExtnLengthInBit = 0; |
---|
[1207] | 1828 | if( slice->getPPS()->getPocResetInfoPresentFlag() ) |
---|
[1029] | 1829 | { |
---|
| 1830 | shExtnLengthInBit += 2; |
---|
| 1831 | } |
---|
[1207] | 1832 | |
---|
| 1833 | if( slice->getPocResetIdc() > 0 ) |
---|
[1029] | 1834 | { |
---|
| 1835 | shExtnLengthInBit += 6; |
---|
| 1836 | } |
---|
[1207] | 1837 | |
---|
| 1838 | if( slice->getPocResetIdc() == 3 ) |
---|
[1029] | 1839 | { |
---|
| 1840 | shExtnLengthInBit += (slice->getSPS()->getBitsForPOC() + 1); |
---|
| 1841 | } |
---|
| 1842 | |
---|
[1207] | 1843 | if( !slice->getPocMsbValRequiredFlag() && slice->getVPS()->getVpsPocLsbAlignedFlag() ) |
---|
[1029] | 1844 | { |
---|
| 1845 | shExtnLengthInBit++; |
---|
| 1846 | } |
---|
| 1847 | else |
---|
| 1848 | { |
---|
| 1849 | if( slice->getPocMsbValRequiredFlag() ) |
---|
| 1850 | { |
---|
| 1851 | slice->setPocMsbValPresentFlag( true ); |
---|
| 1852 | } |
---|
| 1853 | else |
---|
| 1854 | { |
---|
| 1855 | slice->setPocMsbValPresentFlag( false ); |
---|
| 1856 | } |
---|
| 1857 | } |
---|
| 1858 | |
---|
[1207] | 1859 | if( slice->getPocMsbNeeded() ) |
---|
[1029] | 1860 | { |
---|
| 1861 | slice->setPocMsbValPresentFlag(true); |
---|
| 1862 | } |
---|
| 1863 | |
---|
[1207] | 1864 | if( slice->getPocMsbValPresentFlag() ) |
---|
[1029] | 1865 | { |
---|
| 1866 | UInt lengthVal = 1; |
---|
| 1867 | UInt tempVal = (slice->getPocMsbVal() / maxPocLsb) + 1; |
---|
| 1868 | assert ( tempVal ); |
---|
| 1869 | while( 1 != tempVal ) |
---|
| 1870 | { |
---|
| 1871 | tempVal >>= 1; |
---|
| 1872 | lengthVal += 2; |
---|
| 1873 | } |
---|
| 1874 | shExtnLengthInBit += lengthVal; |
---|
| 1875 | } |
---|
[1207] | 1876 | |
---|
[1029] | 1877 | Int shExtnAdditionalBits = 0; |
---|
[1207] | 1878 | |
---|
| 1879 | if( shExtnLengthInBit % 8 != 0 ) |
---|
[1029] | 1880 | { |
---|
| 1881 | shExtnAdditionalBits = 8 - (shExtnLengthInBit % 8); |
---|
| 1882 | } |
---|
[1207] | 1883 | |
---|
[1029] | 1884 | Int shExtnLength = (shExtnLengthInBit + shExtnAdditionalBits) / 8; |
---|
| 1885 | WRITE_UVLC( shExtnLength, "slice_header_extension_length" ); |
---|
| 1886 | |
---|
[1207] | 1887 | if( slice->getPPS()->getPocResetInfoPresentFlag() ) |
---|
[1029] | 1888 | { |
---|
| 1889 | WRITE_CODE( slice->getPocResetIdc(), 2, "poc_reset_idc"); |
---|
| 1890 | } |
---|
[1207] | 1891 | if( slice->getPocResetIdc() > 0 ) |
---|
[1029] | 1892 | { |
---|
| 1893 | WRITE_CODE( slice->getPocResetPeriodId(), 6, "poc_reset_period_id"); |
---|
| 1894 | } |
---|
[1207] | 1895 | if( slice->getPocResetIdc() == 3 ) |
---|
[1029] | 1896 | { |
---|
| 1897 | WRITE_FLAG( slice->getFullPocResetFlag() ? 1 : 0, "full_poc_reset_flag"); |
---|
| 1898 | WRITE_CODE( slice->getPocLsbVal(), slice->getSPS()->getBitsForPOC(), "poc_lsb_val"); |
---|
| 1899 | } |
---|
| 1900 | |
---|
[1199] | 1901 | if( !slice->getPocMsbValRequiredFlag() && slice->getVPS()->getVpsPocLsbAlignedFlag() ) |
---|
[1029] | 1902 | { |
---|
| 1903 | WRITE_FLAG( slice->getPocMsbValPresentFlag(), "poc_msb_cycle_val_present_flag" ); |
---|
| 1904 | } |
---|
[1199] | 1905 | |
---|
| 1906 | if( slice->getPocMsbValPresentFlag() ) |
---|
[1029] | 1907 | { |
---|
| 1908 | assert(slice->getPocMsbVal() % maxPocLsb == 0); |
---|
| 1909 | WRITE_UVLC(slice->getPocMsbVal() / maxPocLsb, "poc_msb_cycle_val"); |
---|
| 1910 | } |
---|
[1199] | 1911 | |
---|
[1207] | 1912 | for(Int i = 0; i < shExtnAdditionalBits; i++) |
---|
[1029] | 1913 | { |
---|
| 1914 | WRITE_FLAG( 1, "slice_segment_header_extension_data_bit"); |
---|
| 1915 | } |
---|
| 1916 | } |
---|
[1199] | 1917 | |
---|
[1029] | 1918 | shBitsWrittenTillNow += ( getNumberOfWrittenBits() - tmpBitsBeforeWriting ); |
---|
| 1919 | |
---|
| 1920 | // Slice header byte_alignment() included in xAttachSliceDataToNalUnit |
---|
| 1921 | } |
---|
| 1922 | |
---|
[1235] | 1923 | Void TEncCavlc::codeVPSExtension( const TComVPS *vps ) |
---|
[313] | 1924 | { |
---|
[644] | 1925 | Int NumOutputLayersInOutputLayerSet[MAX_VPS_LAYER_SETS_PLUS1]; |
---|
| 1926 | Int OlsHighestOutputLayerId[MAX_VPS_LAYER_SETS_PLUS1]; |
---|
[1169] | 1927 | |
---|
[864] | 1928 | if( vps->getMaxLayers() > 1 && vps->getBaseLayerInternalFlag() ) |
---|
| 1929 | { |
---|
[942] | 1930 | codePTL( vps->getPTL(1), false, vps->getMaxTLayers() - 1 ); |
---|
[864] | 1931 | } |
---|
[1161] | 1932 | |
---|
[313] | 1933 | UInt i = 0, j = 0; |
---|
[1113] | 1934 | |
---|
[313] | 1935 | WRITE_FLAG( vps->getSplittingFlag(), "splitting_flag" ); |
---|
| 1936 | |
---|
| 1937 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
| 1938 | { |
---|
| 1939 | WRITE_FLAG( vps->getScalabilityMask(i), "scalability_mask[i]" ); |
---|
| 1940 | } |
---|
| 1941 | |
---|
| 1942 | for(j = 0; j < vps->getNumScalabilityTypes() - vps->getSplittingFlag(); j++) |
---|
| 1943 | { |
---|
| 1944 | WRITE_CODE( vps->getDimensionIdLen(j) - 1, 3, "dimension_id_len_minus1[j]" ); |
---|
| 1945 | } |
---|
| 1946 | |
---|
[815] | 1947 | // The value of dimBitOffset[ NumScalabilityTypes ] is set equal to 6. |
---|
[345] | 1948 | if(vps->getSplittingFlag()) |
---|
| 1949 | { |
---|
| 1950 | UInt splDimSum=0; |
---|
| 1951 | for(j = 0; j < vps->getNumScalabilityTypes(); j++) |
---|
| 1952 | { |
---|
| 1953 | splDimSum+=(vps->getDimensionIdLen(j)); |
---|
| 1954 | } |
---|
| 1955 | assert(splDimSum<=6); |
---|
| 1956 | } |
---|
| 1957 | |
---|
[313] | 1958 | WRITE_FLAG( vps->getNuhLayerIdPresentFlag(), "vps_nuh_layer_id_present_flag" ); |
---|
| 1959 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1960 | { |
---|
| 1961 | if( vps->getNuhLayerIdPresentFlag() ) |
---|
| 1962 | { |
---|
| 1963 | WRITE_CODE( vps->getLayerIdInNuh(i), 6, "layer_id_in_nuh[i]" ); |
---|
| 1964 | } |
---|
[494] | 1965 | |
---|
| 1966 | if( !vps->getSplittingFlag() ) |
---|
| 1967 | { |
---|
[1057] | 1968 | for(j = 0; j < vps->getNumScalabilityTypes(); j++) |
---|
| 1969 | { |
---|
| 1970 | UInt bits = vps->getDimensionIdLen(j); |
---|
| 1971 | WRITE_CODE( vps->getDimensionId(i, j), bits, "dimension_id[i][j]" ); |
---|
| 1972 | } |
---|
[313] | 1973 | } |
---|
| 1974 | } |
---|
[1161] | 1975 | |
---|
[1190] | 1976 | WRITE_CODE( vps->getViewIdLen( ), 4, "view_id_len" ); |
---|
| 1977 | assert ( vps->getNumViews() >= (1<<vps->getViewIdLen()) ); |
---|
[442] | 1978 | |
---|
[547] | 1979 | if ( vps->getViewIdLen() > 0 ) |
---|
| 1980 | { |
---|
[1190] | 1981 | for( i = 0; i < vps->getNumViews(); i++ ) |
---|
| 1982 | { |
---|
| 1983 | WRITE_CODE( vps->getViewIdVal( i ), vps->getViewIdLen( ), "view_id_val[i]" ); |
---|
| 1984 | } |
---|
[1029] | 1985 | } |
---|
[547] | 1986 | |
---|
[1057] | 1987 | for( Int layerCtr = 1; layerCtr < vps->getMaxLayers(); layerCtr++) |
---|
[313] | 1988 | { |
---|
| 1989 | for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
| 1990 | { |
---|
| 1991 | WRITE_FLAG(vps->getDirectDependencyFlag(layerCtr, refLayerCtr), "direct_dependency_flag[i][j]" ); |
---|
| 1992 | } |
---|
| 1993 | } |
---|
[1148] | 1994 | |
---|
[1172] | 1995 | if( vps->getNumIndependentLayers() > 1 ) |
---|
[862] | 1996 | { |
---|
| 1997 | WRITE_UVLC( vps->getNumAddLayerSets(), "num_add_layer_sets" ); |
---|
[1172] | 1998 | |
---|
| 1999 | for( i = 0; i < vps->getNumAddLayerSets(); i++ ) |
---|
[862] | 2000 | { |
---|
[1172] | 2001 | for( j = 1; j < vps->getNumIndependentLayers(); j++ ) |
---|
[862] | 2002 | { |
---|
[1172] | 2003 | Int len = 1; |
---|
| 2004 | while( (1 << len) < (vps->getNumLayersInTreePartition(j) + 1) ) |
---|
[862] | 2005 | { |
---|
| 2006 | len++; |
---|
| 2007 | } |
---|
| 2008 | WRITE_CODE(vps->getHighestLayerIdxPlus1(i, j), len, "highest_layer_idx_plus1[i][j]"); |
---|
| 2009 | } |
---|
| 2010 | } |
---|
| 2011 | } |
---|
[1152] | 2012 | |
---|
| 2013 | WRITE_FLAG( vps->getMaxTSLayersPresentFlag(), "vps_sub_layers_max_minus1_present_flag"); |
---|
| 2014 | if( vps->getMaxTSLayersPresentFlag() ) |
---|
| 2015 | { |
---|
| 2016 | for( i = 0; i < vps->getMaxLayers(); i++ ) |
---|
[540] | 2017 | { |
---|
[1152] | 2018 | WRITE_CODE(vps->getMaxTSLayersMinus1(i), 3, "sub_layers_vps_max_minus1[i]" ); |
---|
[540] | 2019 | } |
---|
[1152] | 2020 | } |
---|
| 2021 | |
---|
[442] | 2022 | WRITE_FLAG( vps->getMaxTidRefPresentFlag(), "max_tid_ref_present_flag"); |
---|
| 2023 | if (vps->getMaxTidRefPresentFlag()) |
---|
[345] | 2024 | { |
---|
| 2025 | for( i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
| 2026 | { |
---|
[494] | 2027 | for( j = i+1; j <= vps->getMaxLayers() - 1; j++) |
---|
| 2028 | { |
---|
| 2029 | if(vps->getDirectDependencyFlag(j, i)) |
---|
| 2030 | { |
---|
| 2031 | WRITE_CODE(vps->getMaxTidIlRefPicsPlus1(i,j), 3, "max_tid_il_ref_pics_plus1[i][j]" ); |
---|
| 2032 | } |
---|
| 2033 | } |
---|
[345] | 2034 | } |
---|
| 2035 | } |
---|
[815] | 2036 | WRITE_FLAG( vps->getIlpSshSignalingEnabledFlag(), "all_ref_layers_active_flag" ); |
---|
[1170] | 2037 | |
---|
[313] | 2038 | // Profile-tier-level signalling |
---|
[588] | 2039 | WRITE_UVLC( vps->getNumProfileTierLevel() - 1, "vps_num_profile_tier_level_minus1"); |
---|
[1154] | 2040 | |
---|
[866] | 2041 | Int const numBitsForPtlIdx = vps->calculateLenOfSyntaxElement( vps->getNumProfileTierLevel() ); |
---|
[1154] | 2042 | |
---|
[942] | 2043 | //Do something here to make sure the loop is correct to consider base layer internal stuff |
---|
[1182] | 2044 | |
---|
| 2045 | for( Int idx = vps->getBaseLayerInternalFlag() ? 2 : 1; idx < vps->getNumProfileTierLevel(); idx++ ) |
---|
[313] | 2046 | { |
---|
| 2047 | WRITE_FLAG( vps->getProfilePresentFlag(idx), "vps_profile_present_flag[i]" ); |
---|
[1182] | 2048 | |
---|
[942] | 2049 | codePTL( vps->getPTL(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 ); |
---|
[313] | 2050 | } |
---|
| 2051 | |
---|
[713] | 2052 | Int numOutputLayerSets = vps->getNumOutputLayerSets(); |
---|
| 2053 | Int numAddOutputLayerSets = numOutputLayerSets - (Int)vps->getNumLayerSets(); |
---|
| 2054 | |
---|
[815] | 2055 | // The value of num_add_olss shall be in the range of 0 to 1023, inclusive. |
---|
[713] | 2056 | assert( numAddOutputLayerSets >= 0 && numAddOutputLayerSets < 1024 ); |
---|
| 2057 | |
---|
| 2058 | if( vps->getNumLayerSets() > 1 ) |
---|
| 2059 | { |
---|
[815] | 2060 | WRITE_UVLC( numAddOutputLayerSets, "num_add_olss" ); |
---|
| 2061 | WRITE_CODE( vps->getDefaultTargetOutputLayerIdc(), 2, "default_output_layer_idc" ); |
---|
[713] | 2062 | } |
---|
| 2063 | |
---|
[313] | 2064 | for(i = 1; i < numOutputLayerSets; i++) |
---|
| 2065 | { |
---|
[866] | 2066 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i); |
---|
[1029] | 2067 | if( vps->getNumLayerSets() > 2 && i >= vps->getNumLayerSets() ) |
---|
[313] | 2068 | { |
---|
| 2069 | Int numBits = 1; |
---|
| 2070 | while ((1 << numBits) < (vps->getNumLayerSets() - 1)) |
---|
| 2071 | { |
---|
| 2072 | numBits++; |
---|
| 2073 | } |
---|
[815] | 2074 | WRITE_CODE( vps->getOutputLayerSetIdx(i) - 1, numBits, "layer_set_idx_for_ols_minus1"); |
---|
[588] | 2075 | } |
---|
[1172] | 2076 | |
---|
| 2077 | if( i > vps->getVpsNumLayerSetsMinus1() || vps->getDefaultTargetOutputLayerIdc() >= 2 ) //Instead of == 2, >= 2 is used to follow the agreement that value 3 should be interpreted as 2 |
---|
[588] | 2078 | { |
---|
[1172] | 2079 | for( j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++ ) |
---|
[313] | 2080 | { |
---|
| 2081 | WRITE_FLAG( vps->getOutputLayerFlag(i,j), "output_layer_flag[i][j]"); |
---|
| 2082 | } |
---|
| 2083 | } |
---|
[1153] | 2084 | |
---|
| 2085 | for( j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++ ) |
---|
[866] | 2086 | { |
---|
[1029] | 2087 | if( vps->getNecessaryLayerFlag(i, j) && (vps->getNumProfileTierLevel() - 1) > 0 ) |
---|
[866] | 2088 | { |
---|
| 2089 | WRITE_CODE( vps->getProfileLevelTierIdx(i, j), numBitsForPtlIdx, "profile_level_tier_idx[i]" ); |
---|
| 2090 | } |
---|
| 2091 | } |
---|
[1124] | 2092 | |
---|
[644] | 2093 | NumOutputLayersInOutputLayerSet[i] = 0; |
---|
[1156] | 2094 | |
---|
| 2095 | for( j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++ ) |
---|
[644] | 2096 | { |
---|
| 2097 | NumOutputLayersInOutputLayerSet[i] += vps->getOutputLayerFlag(i, j); |
---|
[1156] | 2098 | if( vps->getOutputLayerFlag(i, j) ) |
---|
[644] | 2099 | { |
---|
| 2100 | OlsHighestOutputLayerId[i] = vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j); |
---|
| 2101 | } |
---|
| 2102 | } |
---|
[1156] | 2103 | if( NumOutputLayersInOutputLayerSet[i] == 1 && vps->getNumDirectRefLayers(OlsHighestOutputLayerId[i]) > 0 ) |
---|
[644] | 2104 | { |
---|
| 2105 | WRITE_FLAG(vps->getAltOuputLayerFlag(i), "alt_output_layer_flag[i]"); |
---|
| 2106 | } |
---|
[713] | 2107 | |
---|
[1156] | 2108 | assert( NumOutputLayersInOutputLayerSet[i] > 0 ); |
---|
[313] | 2109 | } |
---|
[442] | 2110 | |
---|
[713] | 2111 | // The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive. |
---|
| 2112 | assert( vps->getVpsNumRepFormats() > 0 && vps->getVpsNumRepFormats() <= 256 ); |
---|
| 2113 | |
---|
| 2114 | WRITE_UVLC( vps->getVpsNumRepFormats() - 1, "vps_num_rep_formats_minus1" ); |
---|
| 2115 | |
---|
| 2116 | for(i = 0; i < vps->getVpsNumRepFormats(); i++) |
---|
| 2117 | { |
---|
| 2118 | // Write rep_format_structures |
---|
| 2119 | codeRepFormat( vps->getVpsRepFormat(i) ); |
---|
| 2120 | } |
---|
| 2121 | |
---|
| 2122 | if( vps->getVpsNumRepFormats() > 1 ) |
---|
| 2123 | { |
---|
| 2124 | WRITE_FLAG( vps->getRepFormatIdxPresentFlag(), "rep_format_idx_present_flag"); |
---|
| 2125 | } |
---|
| 2126 | else |
---|
| 2127 | { |
---|
| 2128 | // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0 |
---|
| 2129 | assert( !vps->getRepFormatIdxPresentFlag() ); |
---|
| 2130 | } |
---|
| 2131 | |
---|
| 2132 | if( vps->getRepFormatIdxPresentFlag() ) |
---|
| 2133 | { |
---|
[1029] | 2134 | for( i = vps->getBaseLayerInternalFlag() ? 1 : 0; i < vps->getMaxLayers(); i++ ) |
---|
[713] | 2135 | { |
---|
| 2136 | Int numBits = 1; |
---|
| 2137 | while ((1 << numBits) < (vps->getVpsNumRepFormats())) |
---|
| 2138 | { |
---|
| 2139 | numBits++; |
---|
| 2140 | } |
---|
| 2141 | WRITE_CODE( vps->getVpsRepFormatIdx(i), numBits, "vps_rep_format_idx[i]" ); |
---|
| 2142 | } |
---|
| 2143 | } |
---|
[1119] | 2144 | |
---|
[588] | 2145 | WRITE_FLAG(vps->getMaxOneActiveRefLayerFlag(), "max_one_active_ref_layer_flag"); |
---|
[1199] | 2146 | |
---|
[903] | 2147 | WRITE_FLAG(vps->getVpsPocLsbAlignedFlag(), "vps_poc_lsb_aligned_flag"); |
---|
[1198] | 2148 | |
---|
| 2149 | for( i = 1; i< vps->getMaxLayers(); i++ ) |
---|
[313] | 2150 | { |
---|
[494] | 2151 | if( vps->getNumDirectRefLayers( vps->getLayerIdInNuh(i) ) == 0 ) |
---|
[313] | 2152 | { |
---|
[494] | 2153 | WRITE_FLAG(vps->getPocLsbNotPresentFlag(i), "poc_lsb_not_present_flag[i]"); |
---|
[313] | 2154 | } |
---|
| 2155 | } |
---|
[1125] | 2156 | |
---|
[588] | 2157 | codeVpsDpbSizeTable(vps); |
---|
[1148] | 2158 | |
---|
[313] | 2159 | WRITE_UVLC( vps->getDirectDepTypeLen()-2, "direct_dep_type_len_minus2"); |
---|
[1146] | 2160 | |
---|
[540] | 2161 | WRITE_FLAG(vps->getDefaultDirectDependencyTypeFlag(), "default_direct_dependency_flag"); |
---|
[1146] | 2162 | |
---|
| 2163 | if( vps->getDefaultDirectDependencyTypeFlag() ) |
---|
[313] | 2164 | { |
---|
[540] | 2165 | WRITE_CODE( vps->getDefaultDirectDependencyType(), vps->getDirectDepTypeLen(), "default_direct_dependency_type" ); |
---|
| 2166 | } |
---|
| 2167 | else |
---|
| 2168 | { |
---|
[1029] | 2169 | for( i = vps->getBaseLayerInternalFlag() ? 1 : 2; i < vps->getMaxLayers(); i++ ) |
---|
[313] | 2170 | { |
---|
[1029] | 2171 | for( j = vps->getBaseLayerInternalFlag() ? 0 : 1; j < i; j++ ) |
---|
[313] | 2172 | { |
---|
[540] | 2173 | if (vps->getDirectDependencyFlag(i, j)) |
---|
| 2174 | { |
---|
| 2175 | WRITE_CODE( vps->getDirectDependencyType(i, j), vps->getDirectDepTypeLen(), "direct_dependency_type[i][j]" ); |
---|
| 2176 | } |
---|
[313] | 2177 | } |
---|
| 2178 | } |
---|
| 2179 | } |
---|
[547] | 2180 | |
---|
[713] | 2181 | // The value of vps_non_vui_extension_length shall be in the range of 0 to 4096, inclusive. |
---|
| 2182 | assert( vps->getVpsNonVuiExtLength() >= 0 && vps->getVpsNonVuiExtLength() <= 4096 ); |
---|
| 2183 | |
---|
[588] | 2184 | WRITE_UVLC( vps->getVpsNonVuiExtLength(), "vps_non_vui_extension_length" ); |
---|
[1165] | 2185 | |
---|
| 2186 | for( i = 1; i <= vps->getVpsNonVuiExtLength(); i++ ) |
---|
[644] | 2187 | { |
---|
| 2188 | WRITE_CODE(1, 8, "vps_non_vui_extension_data_byte"); |
---|
| 2189 | } |
---|
[1235] | 2190 | |
---|
[713] | 2191 | WRITE_FLAG( vps->getVpsVuiPresentFlag() ? 1 : 0, "vps_vui_present_flag" ); |
---|
[1113] | 2192 | |
---|
[547] | 2193 | if(vps->getVpsVuiPresentFlag()) // Should be conditioned on the value of vps_vui_present_flag |
---|
| 2194 | { |
---|
| 2195 | while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) |
---|
| 2196 | { |
---|
| 2197 | WRITE_FLAG(1, "vps_vui_alignment_bit_equal_to_one"); |
---|
| 2198 | } |
---|
[1113] | 2199 | |
---|
[547] | 2200 | codeVPSVUI(vps); |
---|
| 2201 | } |
---|
[313] | 2202 | } |
---|
[815] | 2203 | |
---|
[1235] | 2204 | Void TEncCavlc::codeRepFormat( const RepFormat *repFormat ) |
---|
[442] | 2205 | { |
---|
[713] | 2206 | WRITE_CODE( repFormat->getPicWidthVpsInLumaSamples (), 16, "pic_width_vps_in_luma_samples" ); |
---|
| 2207 | WRITE_CODE( repFormat->getPicHeightVpsInLumaSamples(), 16, "pic_height_vps_in_luma_samples" ); |
---|
| 2208 | WRITE_FLAG( repFormat->getChromaAndBitDepthVpsPresentFlag(), "chroma_and_bit_depth_vps_present_flag" ); |
---|
[540] | 2209 | |
---|
[713] | 2210 | if( repFormat->getChromaAndBitDepthVpsPresentFlag() ) |
---|
| 2211 | { |
---|
| 2212 | WRITE_CODE( repFormat->getChromaFormatVpsIdc(), 2, "chroma_format_vps_idc" ); |
---|
[540] | 2213 | |
---|
[713] | 2214 | if( repFormat->getChromaFormatVpsIdc() == 3 ) |
---|
| 2215 | { |
---|
| 2216 | WRITE_FLAG( repFormat->getSeparateColourPlaneVpsFlag(), "separate_colour_plane_vps_flag" ); |
---|
| 2217 | } |
---|
[540] | 2218 | |
---|
[713] | 2219 | assert( repFormat->getBitDepthVpsLuma() >= 8 ); |
---|
| 2220 | assert( repFormat->getBitDepthVpsChroma() >= 8 ); |
---|
| 2221 | WRITE_CODE( repFormat->getBitDepthVpsLuma() - 8, 4, "bit_depth_vps_luma_minus8" ); |
---|
| 2222 | WRITE_CODE( repFormat->getBitDepthVpsChroma() - 8, 4, "bit_depth_vps_chroma_minus8" ); |
---|
| 2223 | } |
---|
[313] | 2224 | |
---|
[869] | 2225 | Window conf = repFormat->getConformanceWindowVps(); |
---|
| 2226 | |
---|
| 2227 | WRITE_FLAG( conf.getWindowEnabledFlag(), "conformance_window_vps_flag" ); |
---|
| 2228 | if (conf.getWindowEnabledFlag()) |
---|
| 2229 | { |
---|
| 2230 | WRITE_UVLC( conf.getWindowLeftOffset(), "conf_win_vps_left_offset" ); |
---|
| 2231 | WRITE_UVLC( conf.getWindowRightOffset(), "conf_win_vps_right_offset" ); |
---|
| 2232 | WRITE_UVLC( conf.getWindowTopOffset(), "conf_win_vps_top_offset" ); |
---|
| 2233 | WRITE_UVLC( conf.getWindowBottomOffset(), "conf_win_vps_bottom_offset" ); |
---|
| 2234 | } |
---|
[442] | 2235 | } |
---|
[1203] | 2236 | |
---|
[1235] | 2237 | Void TEncCavlc::codeVpsDpbSizeTable( const TComVPS *vps ) |
---|
[588] | 2238 | { |
---|
[1189] | 2239 | for( Int i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
---|
[588] | 2240 | { |
---|
| 2241 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
---|
[1135] | 2242 | |
---|
[644] | 2243 | WRITE_FLAG( vps->getSubLayerFlagInfoPresentFlag( i ), "sub_layer_flag_info_present_flag[i]"); |
---|
[1136] | 2244 | |
---|
[872] | 2245 | for(Int j = 0; j <= vps->getMaxSLayersInLayerSetMinus1( layerSetIdxForOutputLayerSet ); j++) |
---|
[588] | 2246 | { |
---|
| 2247 | if( j > 0 && vps->getSubLayerFlagInfoPresentFlag(i) ) |
---|
| 2248 | { |
---|
| 2249 | WRITE_FLAG( vps->getSubLayerDpbInfoPresentFlag( i, j), "sub_layer_dpb_info_present_flag[i]"); |
---|
| 2250 | } |
---|
[1189] | 2251 | |
---|
[588] | 2252 | if( vps->getSubLayerDpbInfoPresentFlag(i, j) ) |
---|
| 2253 | { |
---|
[815] | 2254 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
---|
[588] | 2255 | { |
---|
[1189] | 2256 | if( vps->getNecessaryLayerFlag(i, k) && (vps->getBaseLayerInternalFlag() || (vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, k) != 0)) ) |
---|
| 2257 | { |
---|
| 2258 | WRITE_UVLC( vps->getMaxVpsDecPicBufferingMinus1( i, k, j ), "max_vps_dec_pic_buffering_minus1[i][k][j]" ); |
---|
| 2259 | } |
---|
[588] | 2260 | } |
---|
[1189] | 2261 | |
---|
[1029] | 2262 | WRITE_UVLC( vps->getMaxVpsNumReorderPics( i, j), "max_vps_num_reorder_pics[i][j]" ); |
---|
[1100] | 2263 | |
---|
[588] | 2264 | WRITE_UVLC( vps->getMaxVpsLatencyIncreasePlus1( i, j), "max_vps_latency_increase_plus1[i][j]" ); |
---|
| 2265 | } |
---|
| 2266 | } |
---|
| 2267 | } |
---|
| 2268 | } |
---|
[815] | 2269 | |
---|
[1235] | 2270 | Void TEncCavlc::codeVPSVUI( const TComVPS *vps ) |
---|
[442] | 2271 | { |
---|
| 2272 | Int i,j; |
---|
[540] | 2273 | WRITE_FLAG(vps->getCrossLayerPictureTypeAlignFlag(), "cross_layer_pic_type_aligned_flag"); |
---|
[1235] | 2274 | |
---|
| 2275 | if( !vps->getCrossLayerPictureTypeAlignFlag() ) |
---|
[540] | 2276 | { |
---|
| 2277 | WRITE_FLAG(vps->getCrossLayerIrapAlignFlag(), "cross_layer_irap_aligned_flag"); |
---|
| 2278 | } |
---|
[1011] | 2279 | else |
---|
| 2280 | { |
---|
[1128] | 2281 | // When not present, the value of cross_layer_irap_aligned_flag is inferred to be equal to vps_vui_present_flag, |
---|
[1235] | 2282 | assert( vps->getCrossLayerIrapAlignFlag() == true ); |
---|
[1011] | 2283 | } |
---|
[1126] | 2284 | |
---|
[1128] | 2285 | if( vps->getCrossLayerIrapAlignFlag() ) |
---|
[1011] | 2286 | { |
---|
| 2287 | WRITE_FLAG(vps->getCrossLayerAlignedIdrOnlyFlag(), "all_layers_idr_aligned_flag"); |
---|
| 2288 | } |
---|
| 2289 | |
---|
[442] | 2290 | WRITE_FLAG( vps->getBitRatePresentVpsFlag(), "bit_rate_present_vps_flag" ); |
---|
| 2291 | WRITE_FLAG( vps->getPicRatePresentVpsFlag(), "pic_rate_present_vps_flag" ); |
---|
| 2292 | |
---|
| 2293 | if( vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag() ) |
---|
| 2294 | { |
---|
[889] | 2295 | for( i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getNumLayerSets(); i++ ) |
---|
[442] | 2296 | { |
---|
[815] | 2297 | for( j = 0; j <= vps->getMaxSLayersInLayerSetMinus1(i); j++ ) |
---|
[442] | 2298 | { |
---|
| 2299 | if( vps->getBitRatePresentVpsFlag() ) |
---|
| 2300 | { |
---|
[713] | 2301 | WRITE_FLAG( vps->getBitRatePresentFlag( i, j), "bit_rate_present_flag[i][j]" ); |
---|
[442] | 2302 | } |
---|
[1172] | 2303 | |
---|
[442] | 2304 | if( vps->getPicRatePresentVpsFlag() ) |
---|
| 2305 | { |
---|
[713] | 2306 | WRITE_FLAG( vps->getPicRatePresentFlag( i, j), "pic_rate_present_flag[i][j]" ); |
---|
[442] | 2307 | } |
---|
[1172] | 2308 | |
---|
[442] | 2309 | if( vps->getBitRatePresentFlag(i, j) ) |
---|
| 2310 | { |
---|
| 2311 | WRITE_CODE( vps->getAvgBitRate( i, j ), 16, "avg_bit_rate[i][j]" ); |
---|
| 2312 | WRITE_CODE( vps->getAvgBitRate( i, j ), 16, "max_bit_rate[i][j]" ); |
---|
| 2313 | } |
---|
[1172] | 2314 | |
---|
[442] | 2315 | if( vps->getPicRatePresentFlag(i, j) ) |
---|
| 2316 | { |
---|
| 2317 | WRITE_CODE( vps->getConstPicRateIdc( i, j), 2 , "constant_pic_rate_idc[i][j]" ); |
---|
| 2318 | WRITE_CODE( vps->getConstPicRateIdc( i, j), 16, "avg_pic_rate[i][j]" ); |
---|
| 2319 | } |
---|
| 2320 | } |
---|
| 2321 | } |
---|
| 2322 | } |
---|
[1167] | 2323 | |
---|
[588] | 2324 | WRITE_FLAG( vps->getVideoSigPresentVpsFlag(), "video_signal_info_idx_present_flag" ); |
---|
| 2325 | if (vps->getVideoSigPresentVpsFlag()) |
---|
| 2326 | { |
---|
| 2327 | WRITE_CODE(vps->getNumVideoSignalInfo()-1, 4, "vps_num_video_signal_info_minus1" ); |
---|
| 2328 | } |
---|
| 2329 | |
---|
| 2330 | for(i = 0; i < vps->getNumVideoSignalInfo(); i++) |
---|
| 2331 | { |
---|
| 2332 | WRITE_CODE(vps->getVideoVPSFormat(i), 3, "video_vps_format" ); |
---|
| 2333 | WRITE_FLAG(vps->getVideoFullRangeVpsFlag(i), "video_full_range_vps_flag" ); |
---|
| 2334 | WRITE_CODE(vps->getColorPrimaries(i), 8, "color_primaries_vps" ); |
---|
| 2335 | WRITE_CODE(vps->getTransCharacter(i), 8, "transfer_characteristics_vps" ); |
---|
| 2336 | WRITE_CODE(vps->getMaxtrixCoeff(i), 8, "matrix_coeffs_vps" ); |
---|
| 2337 | } |
---|
| 2338 | |
---|
[1166] | 2339 | if( vps->getVideoSigPresentVpsFlag() && vps->getNumVideoSignalInfo() > 1 ) |
---|
[588] | 2340 | { |
---|
[1166] | 2341 | for( i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++ ) |
---|
[839] | 2342 | { |
---|
| 2343 | WRITE_CODE( vps->getVideoSignalInfoIdx(i), 4, "vps_video_signal_info_idx" ); |
---|
| 2344 | } |
---|
[588] | 2345 | } |
---|
[1167] | 2346 | |
---|
[540] | 2347 | WRITE_FLAG( vps->getTilesNotInUseFlag() ? 1 : 0 , "tiles_not_in_use_flag" ); |
---|
[1176] | 2348 | |
---|
| 2349 | if( !vps->getTilesNotInUseFlag() ) |
---|
[540] | 2350 | { |
---|
[1029] | 2351 | for( i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++ ) |
---|
[540] | 2352 | { |
---|
| 2353 | WRITE_FLAG( vps->getTilesInUseFlag(i) ? 1 : 0 , "tiles_in_use_flag[ i ]" ); |
---|
[1176] | 2354 | |
---|
| 2355 | if( vps->getTilesInUseFlag(i) ) |
---|
[540] | 2356 | { |
---|
| 2357 | WRITE_FLAG( vps->getLoopFilterNotAcrossTilesFlag(i) ? 1 : 0 , "loop_filter_not_across_tiles_flag[ i ]" ); |
---|
| 2358 | } |
---|
| 2359 | } |
---|
[815] | 2360 | |
---|
[1029] | 2361 | for( i = vps->getBaseLayerInternalFlag() ? 1 : 2; i < vps->getMaxLayers(); i++ ) |
---|
[540] | 2362 | { |
---|
| 2363 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
---|
| 2364 | { |
---|
[1176] | 2365 | UInt layerIdx = vps->getLayerIdxInVps(vps->getRefLayerId(vps->getLayerIdInNuh(i), j)); |
---|
| 2366 | |
---|
| 2367 | if( vps->getTilesInUseFlag(i) && vps->getTilesInUseFlag(layerIdx) ) |
---|
| 2368 | { |
---|
[540] | 2369 | WRITE_FLAG( vps->getTileBoundariesAlignedFlag(i,j) ? 1 : 0 , "tile_boundaries_aligned_flag[i][j]" ); |
---|
| 2370 | } |
---|
| 2371 | } |
---|
| 2372 | } |
---|
| 2373 | } |
---|
[1176] | 2374 | |
---|
[540] | 2375 | WRITE_FLAG( vps->getWppNotInUseFlag() ? 1 : 0 , "wpp_not_in_use_flag" ); |
---|
[1176] | 2376 | |
---|
| 2377 | if( !vps->getWppNotInUseFlag() ) |
---|
[442] | 2378 | { |
---|
[1029] | 2379 | for( i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++ ) |
---|
[442] | 2380 | { |
---|
[540] | 2381 | WRITE_FLAG( vps->getWppInUseFlag(i) ? 1 : 0 , "wpp_in_use_flag[ i ]" ); |
---|
[442] | 2382 | } |
---|
[540] | 2383 | } |
---|
[547] | 2384 | |
---|
| 2385 | WRITE_FLAG(vps->getSingleLayerForNonIrapFlag(), "single_layer_for_non_irap_flag" ); |
---|
[1128] | 2386 | |
---|
[713] | 2387 | // When single_layer_for_non_irap_flag is equal to 0, higher_layer_irap_skip_flag shall be equal to 0 |
---|
| 2388 | if( !vps->getSingleLayerForNonIrapFlag() ) |
---|
| 2389 | { |
---|
| 2390 | assert( !vps->getHigherLayerIrapSkipFlag() ); |
---|
| 2391 | } |
---|
| 2392 | |
---|
[547] | 2393 | WRITE_FLAG(vps->getHigherLayerIrapSkipFlag(), "higher_layer_irap_skip_flag" ); |
---|
[1128] | 2394 | |
---|
[588] | 2395 | WRITE_FLAG( vps->getIlpRestrictedRefLayersFlag() ? 1 : 0 , "ilp_restricted_ref_layers_flag" ); |
---|
| 2396 | if( vps->getIlpRestrictedRefLayersFlag()) |
---|
[442] | 2397 | { |
---|
| 2398 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 2399 | { |
---|
| 2400 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
---|
[980] | 2401 | { |
---|
| 2402 | if (vps->getBaseLayerInternalFlag() || vps->getRefLayerId(vps->getLayerIdInNuh(i), j)) |
---|
| 2403 | { |
---|
| 2404 | WRITE_UVLC(vps->getMinSpatialSegmentOffsetPlus1( i, j), "min_spatial_segment_offset_plus1[i][j]"); |
---|
| 2405 | |
---|
| 2406 | if( vps->getMinSpatialSegmentOffsetPlus1(i,j ) > 0 ) |
---|
[1029] | 2407 | { |
---|
| 2408 | WRITE_FLAG( vps->getCtuBasedOffsetEnabledFlag( i, j) ? 1 : 0 , "ctu_based_offset_enabled_flag[i][j]" ); |
---|
| 2409 | |
---|
| 2410 | if(vps->getCtuBasedOffsetEnabledFlag(i,j)) |
---|
[980] | 2411 | { |
---|
[1029] | 2412 | WRITE_UVLC(vps->getMinHorizontalCtuOffsetPlus1( i, j), "min_horizontal_ctu_offset_plus1[i][j]"); |
---|
[980] | 2413 | } |
---|
[442] | 2414 | } |
---|
[980] | 2415 | } |
---|
[1029] | 2416 | } |
---|
[442] | 2417 | } |
---|
| 2418 | } |
---|
[1167] | 2419 | |
---|
[644] | 2420 | #if O0164_MULTI_LAYER_HRD |
---|
[1185] | 2421 | WRITE_FLAG(vps->getVpsVuiBspHrdPresentFlag(), "vps_vui_bsp_hrd_present_flag" ); |
---|
| 2422 | |
---|
| 2423 | if( vps->getVpsVuiBspHrdPresentFlag() ) |
---|
| 2424 | { |
---|
| 2425 | codeVpsVuiBspHrdParams(vps); |
---|
| 2426 | } |
---|
[815] | 2427 | #endif |
---|
[1163] | 2428 | |
---|
[1185] | 2429 | for( i = 1; i < vps->getMaxLayers(); i++ ) |
---|
| 2430 | { |
---|
| 2431 | if( vps->getNumRefLayers(vps->getLayerIdInNuh(i)) == 0 ) |
---|
[644] | 2432 | { |
---|
[1185] | 2433 | WRITE_FLAG(vps->getBaseLayerPSCompatibilityFlag(i), "base_layer_parameter_set_compatibility_flag" ); |
---|
[644] | 2434 | } |
---|
[1185] | 2435 | } |
---|
[442] | 2436 | } |
---|
| 2437 | |
---|
[1235] | 2438 | Void TEncCavlc::codeSPSExtension( const TComSPS* pcSPS ) |
---|
[313] | 2439 | { |
---|
[1029] | 2440 | // more syntax elements to be written here |
---|
[313] | 2441 | |
---|
[1029] | 2442 | // Vertical MV component restriction is not used in SHVC CTC |
---|
| 2443 | WRITE_FLAG( 0, "inter_view_mv_vert_constraint_flag" ); |
---|
[313] | 2444 | } |
---|
| 2445 | |
---|
[1235] | 2446 | Void TEncCavlc::codeVpsVuiBspHrdParams( const TComVPS* vps ) |
---|
[1215] | 2447 | { |
---|
| 2448 | WRITE_UVLC( vps->getVpsNumAddHrdParams(), "vps_num_add_hrd_params" ); |
---|
| 2449 | |
---|
| 2450 | for( Int i = vps->getNumHrdParameters(), j = 0; i < vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams(); i++, j++ ) // j = i - vps->getNumHrdParameters() |
---|
| 2451 | { |
---|
| 2452 | if( i > 0 ) |
---|
| 2453 | { |
---|
| 2454 | WRITE_FLAG( vps->getCprmsAddPresentFlag(j), "cprms_add_present_flag[i]" ); |
---|
| 2455 | } |
---|
| 2456 | |
---|
| 2457 | WRITE_UVLC( vps->getNumSubLayerHrdMinus1(j), "num_sub_layer_hrd_minus1[i]" ); |
---|
| 2458 | |
---|
| 2459 | codeHrdParameters(vps->getBspHrd(j), i == 0 ? true : vps->getCprmsAddPresentFlag(j), vps->getNumSubLayerHrdMinus1(j)); |
---|
| 2460 | } |
---|
| 2461 | |
---|
| 2462 | if( vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams() > 0 ) |
---|
| 2463 | { |
---|
| 2464 | for( Int h = 1; h < vps->getNumOutputLayerSets(); h++ ) |
---|
| 2465 | { |
---|
| 2466 | Int lsIdx = vps->getOutputLayerSetIdx( h ); |
---|
| 2467 | |
---|
| 2468 | WRITE_UVLC( vps->getNumSignalledPartitioningSchemes(h), "num_signalled_partitioning_schemes[h]"); |
---|
| 2469 | |
---|
| 2470 | for( Int j = 1; j < vps->getNumSignalledPartitioningSchemes(h) + 1; j++ ) |
---|
| 2471 | { |
---|
| 2472 | WRITE_UVLC( vps->getNumPartitionsInSchemeMinus1(h, j), "num_partitions_in_scheme_minus1[h][j]" ); |
---|
| 2473 | |
---|
| 2474 | for( Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, j); k++ ) |
---|
| 2475 | { |
---|
| 2476 | for( Int r = 0; r < vps->getNumLayersInIdList( lsIdx ); r++ ) |
---|
| 2477 | { |
---|
| 2478 | WRITE_FLAG( vps->getLayerIncludedInPartitionFlag(h, j, k, r), "layer_included_in_partition_flag[h][j][k][r]" ); |
---|
| 2479 | } |
---|
| 2480 | } |
---|
| 2481 | } |
---|
| 2482 | |
---|
| 2483 | for( Int i = 0; i < vps->getNumSignalledPartitioningSchemes(h) + 1; i++ ) |
---|
| 2484 | { |
---|
| 2485 | for( Int t = 0; t <= vps->getMaxSLayersInLayerSetMinus1(lsIdx); t++ ) |
---|
| 2486 | { |
---|
| 2487 | WRITE_UVLC(vps->getNumBspSchedulesMinus1(h, i, t), "num_bsp_schedules_minus1[h][i][t]"); |
---|
| 2488 | |
---|
| 2489 | for( Int j = 0; j <= vps->getNumBspSchedulesMinus1(h, i, t); j++ ) |
---|
| 2490 | { |
---|
| 2491 | for( Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, i); k++ ) |
---|
| 2492 | { |
---|
| 2493 | if( vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams() > 1 ) |
---|
| 2494 | { |
---|
| 2495 | Int numBits = 1; |
---|
| 2496 | while ((1 << numBits) < (vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams())) |
---|
| 2497 | { |
---|
| 2498 | numBits++; |
---|
| 2499 | } |
---|
| 2500 | |
---|
[1235] | 2501 | WRITE_CODE(vps->getBspHrdIdx(h, i, t, j, k), numBits, "bsp_hrd_idx[h][i][t][j][k]"); |
---|
[1215] | 2502 | } |
---|
| 2503 | |
---|
[1235] | 2504 | WRITE_UVLC( vps->getBspSchedIdx(h, i, t, j, k), "bsp_sched_idx[h][i][t][j][k]"); |
---|
[1215] | 2505 | } |
---|
| 2506 | } |
---|
| 2507 | } |
---|
| 2508 | } |
---|
| 2509 | } |
---|
| 2510 | } |
---|
| 2511 | } |
---|
| 2512 | |
---|
| 2513 | |
---|
[1212] | 2514 | #if CGS_3D_ASYMLUT |
---|
[713] | 2515 | Void TEncCavlc::xCode3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT ) |
---|
| 2516 | { |
---|
[825] | 2517 | UInt uiNumRefLayers = ( UInt )pc3DAsymLUT->getRefLayerNum(); |
---|
| 2518 | WRITE_UVLC( uiNumRefLayers - 1 , "num_cm_ref_layers_minus1" ); |
---|
| 2519 | for( UInt i = 0 ; i < uiNumRefLayers ; i++ ) |
---|
| 2520 | { |
---|
| 2521 | WRITE_CODE( pc3DAsymLUT->getRefLayerId( i ) , 6 , "cm_ref_layer_id" ); |
---|
| 2522 | } |
---|
[1213] | 2523 | |
---|
[713] | 2524 | assert( pc3DAsymLUT->getCurOctantDepth() < 4 ); |
---|
| 2525 | WRITE_CODE( pc3DAsymLUT->getCurOctantDepth() , 2 , "cm_octant_depth" ); |
---|
| 2526 | assert( pc3DAsymLUT->getCurYPartNumLog2() < 4 ); |
---|
| 2527 | WRITE_CODE( pc3DAsymLUT->getCurYPartNumLog2() , 2 , "cm_y_part_num_log2" ); |
---|
| 2528 | assert( pc3DAsymLUT->getInputBitDepthY() < 16 ); |
---|
[1213] | 2529 | |
---|
[882] | 2530 | WRITE_UVLC( pc3DAsymLUT->getInputBitDepthY() - 8 , "cm_input_luma_bit_depth_minus8" ); |
---|
| 2531 | WRITE_UVLC( pc3DAsymLUT->getInputBitDepthC() - 8 , "cm_input_chroma_bit_depth_minus8" ); |
---|
| 2532 | WRITE_UVLC( pc3DAsymLUT->getOutputBitDepthY() - 8 , "cm_output_luma_bit_depth_minus8" ); |
---|
| 2533 | WRITE_UVLC( pc3DAsymLUT->getOutputBitDepthC() - 8 , "cm_output_chroma_bit_depth_minus8" ); |
---|
[1213] | 2534 | |
---|
[713] | 2535 | assert( pc3DAsymLUT->getResQuantBit() < 4 ); |
---|
| 2536 | WRITE_CODE( pc3DAsymLUT->getResQuantBit() , 2 , "cm_res_quant_bit" ); |
---|
[1215] | 2537 | |
---|
[826] | 2538 | xFindDeltaBits( pc3DAsymLUT ); |
---|
| 2539 | assert(pc3DAsymLUT->getDeltaBits() >=1 && pc3DAsymLUT->getDeltaBits() <= 4); |
---|
| 2540 | WRITE_CODE( pc3DAsymLUT->getDeltaBits()-1 , 2 , "cm_delta_bit" ); |
---|
[1214] | 2541 | |
---|
[825] | 2542 | if( pc3DAsymLUT->getCurOctantDepth() == 1 ) |
---|
| 2543 | { |
---|
| 2544 | WRITE_SVLC( pc3DAsymLUT->getAdaptChromaThresholdU() - ( 1 << ( pc3DAsymLUT->getInputBitDepthC() - 1 ) ) , "cm_adapt_threshold_u_delta" ); |
---|
| 2545 | WRITE_SVLC( pc3DAsymLUT->getAdaptChromaThresholdV() - ( 1 << ( pc3DAsymLUT->getInputBitDepthC() - 1 ) ) , "cm_adapt_threshold_v_delta" ); |
---|
| 2546 | } |
---|
[713] | 2547 | |
---|
[852] | 2548 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
[825] | 2549 | pc3DAsymLUT->xInitCuboids(); |
---|
| 2550 | #endif |
---|
[713] | 2551 | xCode3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() ); |
---|
[852] | 2552 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
| 2553 | xCuboidsFilledCheck( false ); |
---|
| 2554 | pc3DAsymLUT->display( false ); |
---|
[825] | 2555 | #endif |
---|
[713] | 2556 | } |
---|
| 2557 | |
---|
| 2558 | Void TEncCavlc::xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength ) |
---|
| 2559 | { |
---|
| 2560 | UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth(); |
---|
| 2561 | if( nDepth < pc3DAsymLUT->getCurOctantDepth() ) |
---|
| 2562 | WRITE_FLAG( uiOctantSplit , "split_octant_flag" ); |
---|
| 2563 | Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2(); |
---|
| 2564 | if( uiOctantSplit ) |
---|
| 2565 | { |
---|
| 2566 | Int nHalfLength = nLength >> 1; |
---|
| 2567 | for( Int l = 0 ; l < 2 ; l++ ) |
---|
| 2568 | { |
---|
| 2569 | for( Int m = 0 ; m < 2 ; m++ ) |
---|
| 2570 | { |
---|
| 2571 | for( Int n = 0 ; n < 2 ; n++ ) |
---|
| 2572 | { |
---|
| 2573 | xCode3DAsymLUTOctant( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength ); |
---|
| 2574 | } |
---|
| 2575 | } |
---|
| 2576 | } |
---|
| 2577 | } |
---|
| 2578 | else |
---|
| 2579 | { |
---|
[826] | 2580 | Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-pc3DAsymLUT->getDeltaBits() ; |
---|
| 2581 | nFLCbits = nFLCbits >= 0 ? nFLCbits : 0; |
---|
[1215] | 2582 | |
---|
[713] | 2583 | for( Int l = 0 ; l < nYPartNum ; l++ ) |
---|
| 2584 | { |
---|
[878] | 2585 | Int shift = pc3DAsymLUT->getCurOctantDepth() - nDepth ; |
---|
[1217] | 2586 | |
---|
[713] | 2587 | for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ ) |
---|
| 2588 | { |
---|
[825] | 2589 | SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + (l<<shift) , uIdx , vIdx , nVertexIdx ); |
---|
[1217] | 2590 | |
---|
[713] | 2591 | UInt uiCodeVertex = sRes.Y != 0 || sRes.U != 0 || sRes.V != 0; |
---|
| 2592 | WRITE_FLAG( uiCodeVertex , "coded_vertex_flag" ); |
---|
| 2593 | if( uiCodeVertex ) |
---|
| 2594 | { |
---|
[826] | 2595 | xWriteParam( sRes.Y, nFLCbits ); |
---|
| 2596 | xWriteParam( sRes.U, nFLCbits ); |
---|
| 2597 | xWriteParam( sRes.V, nFLCbits ); |
---|
[713] | 2598 | } |
---|
| 2599 | } |
---|
[852] | 2600 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
[825] | 2601 | pc3DAsymLUT->xSetExplicit( yIdx + (l<<shift) , uIdx , vIdx ); |
---|
| 2602 | #endif |
---|
[713] | 2603 | } |
---|
| 2604 | } |
---|
| 2605 | } |
---|
[825] | 2606 | |
---|
[826] | 2607 | Void TEncCavlc::xWriteParam( Int param, UInt rParam) |
---|
[825] | 2608 | { |
---|
| 2609 | Int codeNumber = abs(param); |
---|
| 2610 | WRITE_UVLC(codeNumber / (1 << rParam), "quotient"); |
---|
| 2611 | WRITE_CODE((codeNumber % (1 << rParam)), rParam, "remainder"); |
---|
| 2612 | if (abs(param)) |
---|
| 2613 | WRITE_FLAG( param <0, "sign"); |
---|
| 2614 | } |
---|
| 2615 | |
---|
[826] | 2616 | Void TEncCavlc::xFindDeltaBits( TCom3DAsymLUT * pc3DAsymLUT ) |
---|
| 2617 | { |
---|
| 2618 | Int nDeltaBits; |
---|
| 2619 | Int nBestDeltaBits = -1; |
---|
| 2620 | Int nBestBits = MAX_INT; |
---|
| 2621 | for( nDeltaBits = 1; nDeltaBits < 5; nDeltaBits++) |
---|
| 2622 | { |
---|
| 2623 | Int nCurBits = 0; |
---|
| 2624 | xTally3DAsymLUTOctantBits( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth(), nDeltaBits, nCurBits ); |
---|
| 2625 | //printf("%d, %d, %d\n", nDeltaBits, nCurBits, nBestBits); |
---|
| 2626 | if(nCurBits < nBestBits) |
---|
| 2627 | { |
---|
| 2628 | nBestDeltaBits = nDeltaBits; |
---|
| 2629 | nBestBits = nCurBits; |
---|
| 2630 | } |
---|
| 2631 | } |
---|
| 2632 | |
---|
| 2633 | assert(nBestDeltaBits >=1 && nBestDeltaBits < 5); |
---|
| 2634 | pc3DAsymLUT->setDeltaBits(nBestDeltaBits); |
---|
| 2635 | } |
---|
| 2636 | |
---|
| 2637 | Void TEncCavlc::xTally3DAsymLUTOctantBits( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength, Int nDeltaBits, Int& nCurBits ) |
---|
| 2638 | { |
---|
| 2639 | UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth(); |
---|
| 2640 | if( nDepth < pc3DAsymLUT->getCurOctantDepth() ) |
---|
| 2641 | nCurBits ++; |
---|
| 2642 | Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2(); |
---|
| 2643 | if( uiOctantSplit ) |
---|
| 2644 | { |
---|
| 2645 | Int nHalfLength = nLength >> 1; |
---|
| 2646 | for( Int l = 0 ; l < 2 ; l++ ) |
---|
| 2647 | { |
---|
| 2648 | for( Int m = 0 ; m < 2 ; m++ ) |
---|
| 2649 | { |
---|
| 2650 | for( Int n = 0 ; n < 2 ; n++ ) |
---|
| 2651 | { |
---|
| 2652 | xTally3DAsymLUTOctantBits( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength, nDeltaBits, nCurBits ); |
---|
| 2653 | } |
---|
| 2654 | } |
---|
| 2655 | } |
---|
| 2656 | } |
---|
| 2657 | else |
---|
| 2658 | { |
---|
| 2659 | Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-nDeltaBits ; |
---|
| 2660 | nFLCbits = nFLCbits >= 0 ? nFLCbits:0; |
---|
| 2661 | //printf("nFLCbits = %d\n", nFLCbits); |
---|
| 2662 | |
---|
| 2663 | for( Int l = 0 ; l < nYPartNum ; l++ ) |
---|
| 2664 | { |
---|
| 2665 | for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ ) |
---|
| 2666 | { |
---|
| 2667 | SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx ); |
---|
| 2668 | |
---|
| 2669 | UInt uiCodeVertex = sRes.Y != 0 || sRes.U != 0 || sRes.V != 0; |
---|
| 2670 | nCurBits++; |
---|
| 2671 | if( uiCodeVertex ) |
---|
| 2672 | { |
---|
| 2673 | xCheckParamBits( sRes.Y, nFLCbits, nCurBits ); |
---|
| 2674 | xCheckParamBits( sRes.U, nFLCbits, nCurBits ); |
---|
| 2675 | xCheckParamBits( sRes.V, nFLCbits, nCurBits ); |
---|
| 2676 | } |
---|
| 2677 | } |
---|
| 2678 | } |
---|
| 2679 | } |
---|
| 2680 | } |
---|
| 2681 | |
---|
| 2682 | Void TEncCavlc::xCheckParamBits( Int param, Int rParam, Int &nBits) |
---|
| 2683 | { |
---|
| 2684 | Int codeNumber = abs(param); |
---|
| 2685 | Int codeQuotient = codeNumber >> rParam; |
---|
| 2686 | Int qLen; |
---|
| 2687 | |
---|
| 2688 | UInt uiLength = 1; |
---|
| 2689 | UInt uiTemp = ++codeQuotient; |
---|
| 2690 | |
---|
| 2691 | while( 1 != uiTemp ) |
---|
| 2692 | { |
---|
| 2693 | uiTemp >>= 1; |
---|
| 2694 | uiLength += 2; |
---|
| 2695 | } |
---|
| 2696 | |
---|
| 2697 | qLen = (uiLength >> 1); |
---|
| 2698 | qLen += ((uiLength+1) >> 1); |
---|
| 2699 | |
---|
| 2700 | nBits += qLen; |
---|
| 2701 | nBits += rParam; |
---|
| 2702 | if (abs(param)) |
---|
| 2703 | nBits++; |
---|
| 2704 | } |
---|
[1215] | 2705 | #endif //CGS_3D_ASYMLUT |
---|
[1185] | 2706 | |
---|
| 2707 | #endif //SVC_EXTENSION |
---|
[313] | 2708 | //! \} |
---|