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