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