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