[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 | * |
---|
[56] | 6 | * Copyright (c) 2010-2012, 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" |
---|
| 41 | |
---|
[56] | 42 | //! \ingroup TLibEncoder |
---|
| 43 | //! \{ |
---|
[2] | 44 | |
---|
[56] | 45 | #if ENC_DEC_TRACE |
---|
| 46 | |
---|
| 47 | #define WRITE_CODE( value, length, name) xWriteCodeTr ( value, length, name ) |
---|
| 48 | #define WRITE_UVLC( value, name) xWriteUvlcTr ( value, name ) |
---|
| 49 | #define WRITE_SVLC( value, name) xWriteSvlcTr ( value, name ) |
---|
| 50 | #define WRITE_FLAG( value, name) xWriteFlagTr ( value, name ) |
---|
| 51 | |
---|
| 52 | Void xWriteUvlcTr ( UInt value, const Char *pSymbolName); |
---|
| 53 | Void xWriteSvlcTr ( Int value, const Char *pSymbolName); |
---|
| 54 | Void xWriteFlagTr ( UInt value, const Char *pSymbolName); |
---|
| 55 | |
---|
| 56 | Void xTraceSPSHeader (TComSPS *pSPS) |
---|
[2] | 57 | { |
---|
[56] | 58 | fprintf( g_hTrace, "=========== Sequence Parameter Set ID: %d ===========\n", pSPS->getSPSId() ); |
---|
| 59 | } |
---|
[2] | 60 | |
---|
[56] | 61 | Void xTracePPSHeader (TComPPS *pPPS) |
---|
| 62 | { |
---|
| 63 | fprintf( g_hTrace, "=========== Picture Parameter Set ID: %d ===========\n", pPPS->getPPSId() ); |
---|
[2] | 64 | } |
---|
| 65 | |
---|
[56] | 66 | Void xTraceAPSHeader (TComAPS *pAPS) |
---|
[2] | 67 | { |
---|
[56] | 68 | fprintf( g_hTrace, "=========== Adaptation Parameter Set ===========\n"); |
---|
[2] | 69 | } |
---|
| 70 | |
---|
[56] | 71 | Void xTraceSliceHeader (TComSlice *pSlice) |
---|
| 72 | { |
---|
| 73 | fprintf( g_hTrace, "=========== Slice ===========\n"); |
---|
| 74 | } |
---|
[2] | 75 | |
---|
| 76 | |
---|
[56] | 77 | Void TEncCavlc::xWriteCodeTr (UInt value, UInt length, const Char *pSymbolName) |
---|
[2] | 78 | { |
---|
[56] | 79 | xWriteCode (value,length); |
---|
| 80 | fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); |
---|
| 81 | fprintf( g_hTrace, "%-40s u(%d) : %d\n", pSymbolName, length, value ); |
---|
| 82 | } |
---|
[2] | 83 | |
---|
[56] | 84 | Void TEncCavlc::xWriteUvlcTr (UInt value, const Char *pSymbolName) |
---|
| 85 | { |
---|
| 86 | xWriteUvlc (value); |
---|
| 87 | fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); |
---|
| 88 | fprintf( g_hTrace, "%-40s u(v) : %d\n", pSymbolName, value ); |
---|
| 89 | } |
---|
[2] | 90 | |
---|
[56] | 91 | Void TEncCavlc::xWriteSvlcTr (Int value, const Char *pSymbolName) |
---|
| 92 | { |
---|
| 93 | xWriteSvlc(value); |
---|
| 94 | fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); |
---|
| 95 | fprintf( g_hTrace, "%-40s s(v) : %d\n", pSymbolName, value ); |
---|
| 96 | } |
---|
[2] | 97 | |
---|
[56] | 98 | Void TEncCavlc::xWriteFlagTr(UInt value, const Char *pSymbolName) |
---|
| 99 | { |
---|
| 100 | xWriteFlag(value); |
---|
| 101 | fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); |
---|
| 102 | fprintf( g_hTrace, "%-40s u(1) : %d\n", pSymbolName, value ); |
---|
| 103 | } |
---|
[2] | 104 | |
---|
| 105 | #else |
---|
| 106 | |
---|
[56] | 107 | #define WRITE_CODE( value, length, name) xWriteCode ( value, length ) |
---|
| 108 | #define WRITE_UVLC( value, name) xWriteUvlc ( value ) |
---|
| 109 | #define WRITE_SVLC( value, name) xWriteSvlc ( value ) |
---|
| 110 | #define WRITE_FLAG( value, name) xWriteFlag ( value ) |
---|
[2] | 111 | |
---|
| 112 | #endif |
---|
| 113 | |
---|
| 114 | |
---|
| 115 | |
---|
[56] | 116 | // ==================================================================================================================== |
---|
| 117 | // Constructor / destructor / create / destroy |
---|
| 118 | // ==================================================================================================================== |
---|
[2] | 119 | |
---|
[56] | 120 | TEncCavlc::TEncCavlc() |
---|
[2] | 121 | { |
---|
[56] | 122 | m_pcBitIf = NULL; |
---|
| 123 | m_uiCoeffCost = 0; |
---|
| 124 | m_bAlfCtrl = false; |
---|
| 125 | m_uiMaxAlfCtrlDepth = 0; |
---|
| 126 | |
---|
| 127 | m_iSliceGranularity = 0; |
---|
[2] | 128 | } |
---|
| 129 | |
---|
[56] | 130 | TEncCavlc::~TEncCavlc() |
---|
[2] | 131 | { |
---|
| 132 | } |
---|
| 133 | |
---|
[56] | 134 | |
---|
| 135 | // ==================================================================================================================== |
---|
| 136 | // Public member functions |
---|
| 137 | // ==================================================================================================================== |
---|
| 138 | |
---|
| 139 | Void TEncCavlc::resetEntropy() |
---|
[2] | 140 | { |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | /** |
---|
[56] | 144 | * marshall the SEI message sei. |
---|
[2] | 145 | */ |
---|
| 146 | void TEncCavlc::codeSEI(const SEI& sei) |
---|
| 147 | { |
---|
| 148 | writeSEImessage(*m_pcBitIf, sei); |
---|
| 149 | } |
---|
| 150 | |
---|
[56] | 151 | Void TEncCavlc::codeAPSInitInfo(TComAPS* pcAPS) |
---|
[2] | 152 | { |
---|
[56] | 153 | |
---|
| 154 | #if ENC_DEC_TRACE |
---|
| 155 | xTraceAPSHeader(pcAPS); |
---|
[42] | 156 | #endif |
---|
[56] | 157 | //APS ID |
---|
| 158 | WRITE_UVLC( pcAPS->getAPSID(), "aps_id" ); |
---|
[2] | 159 | |
---|
[56] | 160 | WRITE_FLAG( pcAPS->getScalingListEnabled()?1:0, "aps_scaling_list_data_present_flag"); |
---|
| 161 | //DF flag |
---|
| 162 | WRITE_FLAG(pcAPS->getLoopFilterOffsetInAPS()?1:0, "aps_deblocking_filter_flag"); |
---|
| 163 | #if !SAO_UNIT_INTERLEAVING |
---|
| 164 | //SAO flag |
---|
| 165 | WRITE_FLAG( pcAPS->getSaoEnabled()?1:0, "aps_sample_adaptive_offset_flag"); |
---|
[2] | 166 | #endif |
---|
[56] | 167 | #if !LCU_SYNTAX_ALF |
---|
| 168 | //ALF flag |
---|
| 169 | WRITE_FLAG( pcAPS->getAlfEnabled()?1:0, "aps_adaptive_loop_filter_flag"); |
---|
[2] | 170 | #endif |
---|
| 171 | } |
---|
[56] | 172 | #if LCU_SYNTAX_ALF |
---|
| 173 | Void TEncCavlc::codeAPSAlflag(UInt uiCode) |
---|
| 174 | { |
---|
| 175 | WRITE_FLAG(uiCode, "aps_adaptive_loop_filter_flag"); |
---|
| 176 | } |
---|
| 177 | #endif |
---|
[2] | 178 | |
---|
[56] | 179 | Void TEncCavlc::codeDFFlag(UInt uiCode, const Char *pSymbolName) |
---|
[42] | 180 | { |
---|
[56] | 181 | WRITE_FLAG(uiCode, pSymbolName); |
---|
[42] | 182 | } |
---|
[56] | 183 | Void TEncCavlc::codeDFSvlc(Int iCode, const Char *pSymbolName) |
---|
[2] | 184 | { |
---|
[56] | 185 | WRITE_SVLC(iCode, pSymbolName); |
---|
[2] | 186 | } |
---|
| 187 | |
---|
[56] | 188 | #if RPS_IN_SPS |
---|
| 189 | Void TEncCavlc::codeShortTermRefPicSet( TComSPS* pcSPS, TComReferencePictureSet* rps ) |
---|
[42] | 190 | #else |
---|
[56] | 191 | Void TEncCavlc::codeShortTermRefPicSet( TComPPS* pcPPS, TComReferencePictureSet* rps ) |
---|
[42] | 192 | #endif |
---|
[56] | 193 | { |
---|
| 194 | #if PRINT_RPS_INFO |
---|
| 195 | int lastBits = getNumberOfWrittenBits(); |
---|
[2] | 196 | #endif |
---|
[56] | 197 | WRITE_FLAG( rps->getInterRPSPrediction(), "inter_ref_pic_set_prediction_flag" ); // inter_RPS_prediction_flag |
---|
| 198 | if (rps->getInterRPSPrediction()) |
---|
| 199 | { |
---|
| 200 | Int deltaRPS = rps->getDeltaRPS(); |
---|
| 201 | WRITE_UVLC( rps->getDeltaRIdxMinus1(), "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1 |
---|
| 202 | WRITE_CODE( (deltaRPS >=0 ? 0: 1), 1, "delta_rps_sign" ); //delta_rps_sign |
---|
| 203 | WRITE_UVLC( abs(deltaRPS) - 1, "abs_delta_rps_minus1"); // absolute delta RPS minus 1 |
---|
[2] | 204 | |
---|
[56] | 205 | for(Int j=0; j < rps->getNumRefIdc(); j++) |
---|
| 206 | { |
---|
| 207 | Int refIdc = rps->getRefIdc(j); |
---|
| 208 | WRITE_CODE( (refIdc==1? 1: 0), 1, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 |
---|
| 209 | if (refIdc != 1) |
---|
| 210 | { |
---|
| 211 | WRITE_CODE( refIdc>>1, 1, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise. |
---|
| 212 | } |
---|
| 213 | } |
---|
[2] | 214 | } |
---|
[56] | 215 | else |
---|
[2] | 216 | { |
---|
[56] | 217 | WRITE_UVLC( rps->getNumberOfNegativePictures(), "num_negative_pics" ); |
---|
| 218 | WRITE_UVLC( rps->getNumberOfPositivePictures(), "num_positive_pics" ); |
---|
| 219 | Int prev = 0; |
---|
| 220 | for(Int j=0 ; j < rps->getNumberOfNegativePictures(); j++) |
---|
[2] | 221 | { |
---|
[56] | 222 | WRITE_UVLC( prev-rps->getDeltaPOC(j)-1, "delta_poc_s0_minus1" ); |
---|
| 223 | prev = rps->getDeltaPOC(j); |
---|
| 224 | WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s0_flag"); |
---|
[2] | 225 | } |
---|
[56] | 226 | prev = 0; |
---|
| 227 | for(Int j=rps->getNumberOfNegativePictures(); j < rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); j++) |
---|
[2] | 228 | { |
---|
[56] | 229 | WRITE_UVLC( rps->getDeltaPOC(j)-prev-1, "delta_poc_s1_minus1" ); |
---|
| 230 | prev = rps->getDeltaPOC(j); |
---|
| 231 | WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s1_flag" ); |
---|
[2] | 232 | } |
---|
| 233 | } |
---|
[56] | 234 | |
---|
| 235 | #if PRINT_RPS_INFO |
---|
| 236 | printf("irps=%d (%2d bits) ", rps->getInterRPSPrediction(), getNumberOfWrittenBits() - lastBits); |
---|
| 237 | rps->printDeltaPOC(); |
---|
| 238 | #endif |
---|
[2] | 239 | } |
---|
| 240 | |
---|
[56] | 241 | |
---|
| 242 | Void TEncCavlc::codePPS( TComPPS* pcPPS ) |
---|
[2] | 243 | { |
---|
[56] | 244 | #if ENC_DEC_TRACE |
---|
| 245 | xTracePPSHeader (pcPPS); |
---|
[42] | 246 | #endif |
---|
[56] | 247 | #if !RPS_IN_SPS |
---|
| 248 | TComRPSList* rpsList = pcPPS->getRPSList(); |
---|
[2] | 249 | #endif |
---|
[56] | 250 | |
---|
| 251 | WRITE_UVLC( pcPPS->getPPSId(), "pic_parameter_set_id" ); |
---|
| 252 | WRITE_UVLC( pcPPS->getSPSId(), "seq_parameter_set_id" ); |
---|
[2] | 253 | |
---|
[56] | 254 | #if MULTIBITS_DATA_HIDING |
---|
| 255 | WRITE_FLAG( pcPPS->getSignHideFlag(), "sign_data_hiding_flag" ); |
---|
| 256 | if( pcPPS->getSignHideFlag() ) |
---|
[2] | 257 | { |
---|
[56] | 258 | WRITE_CODE(pcPPS->getTSIG(), 4, "sign_hiding_threshold"); |
---|
[2] | 259 | } |
---|
[56] | 260 | #endif |
---|
| 261 | #if CABAC_INIT_FLAG |
---|
| 262 | WRITE_FLAG( pcPPS->getCabacInitPresentFlag() ? 1 : 0, "cabac_init_present_flag" ); |
---|
| 263 | #endif |
---|
| 264 | #if !RPS_IN_SPS |
---|
| 265 | // RPS is put before entropy_coding_mode_flag |
---|
| 266 | // since entropy_coding_mode_flag will probably be removed from the WD |
---|
| 267 | TComReferencePictureSet* rps; |
---|
| 268 | |
---|
| 269 | WRITE_UVLC(rpsList->getNumberOfReferencePictureSets(), "num_short_term_ref_pic_sets" ); |
---|
| 270 | for(UInt i=0; i < rpsList->getNumberOfReferencePictureSets(); i++) |
---|
[2] | 271 | { |
---|
[56] | 272 | rps = rpsList->getReferencePictureSet(i); |
---|
| 273 | codeShortTermRefPicSet(pcPPS,rps); |
---|
[2] | 274 | } |
---|
[56] | 275 | WRITE_FLAG( pcPPS->getLongTermRefsPresent() ? 1 : 0, "long_term_ref_pics_present_flag" ); |
---|
| 276 | #endif |
---|
| 277 | // entropy_coding_mode_flag |
---|
| 278 | // We code the entropy_coding_mode_flag, it's needed for tests. |
---|
| 279 | WRITE_FLAG( pcPPS->getEntropyCodingMode() ? 1 : 0, "entropy_coding_mode_flag" ); |
---|
| 280 | if (pcPPS->getEntropyCodingMode()) |
---|
[2] | 281 | { |
---|
[56] | 282 | #if !WPP_SIMPLIFICATION |
---|
| 283 | WRITE_UVLC( pcPPS->getEntropyCodingSynchro(), "entropy_coding_synchro" ); |
---|
| 284 | WRITE_FLAG( pcPPS->getCabacIstateReset() ? 1 : 0, "cabac_istate_reset" ); |
---|
| 285 | #endif |
---|
| 286 | #if !TILES_OR_ENTROPY_SYNC_IDC |
---|
| 287 | #if !WPP_SIMPLIFICATION |
---|
| 288 | if ( pcPPS->getEntropyCodingSynchro() ) |
---|
| 289 | #endif |
---|
| 290 | { |
---|
| 291 | WRITE_UVLC( pcPPS->getNumSubstreams()-1, "num_substreams_minus1" ); |
---|
| 292 | } |
---|
| 293 | #endif |
---|
[2] | 294 | } |
---|
[56] | 295 | #if !H0566_TLA |
---|
| 296 | WRITE_UVLC( pcPPS->getNumTLayerSwitchingFlags(), "num_temporal_layer_switching_point_flags" ); |
---|
| 297 | for( UInt i = 0; i < pcPPS->getNumTLayerSwitchingFlags(); i++ ) |
---|
[2] | 298 | { |
---|
[56] | 299 | WRITE_FLAG( pcPPS->getTLayerSwitchingFlag( i ) ? 1 : 0 , "temporal_layer_switching_point_flag" ); |
---|
[2] | 300 | } |
---|
[56] | 301 | #endif |
---|
| 302 | // num_ref_idx_l0_default_active_minus1 |
---|
| 303 | // num_ref_idx_l1_default_active_minus1 |
---|
| 304 | WRITE_SVLC( pcPPS->getPicInitQPMinus26(), "pic_init_qp_minus26"); |
---|
| 305 | WRITE_FLAG( pcPPS->getConstrainedIntraPred() ? 1 : 0, "constrained_intra_pred_flag" ); |
---|
| 306 | WRITE_FLAG( pcPPS->getEnableTMVPFlag() ? 1 : 0, "enable_temporal_mvp_flag" ); |
---|
| 307 | WRITE_CODE( pcPPS->getSliceGranularity(), 2, "slice_granularity"); |
---|
| 308 | WRITE_UVLC( pcPPS->getMaxCuDQPDepth() + pcPPS->getUseDQP(), "max_cu_qp_delta_depth" ); |
---|
[2] | 309 | |
---|
[56] | 310 | WRITE_SVLC( pcPPS->getChromaQpOffset(), "chroma_qp_offset" ); |
---|
| 311 | WRITE_SVLC( pcPPS->getChromaQpOffset2nd(), "chroma_qp_offset_2nd" ); |
---|
[2] | 312 | |
---|
[56] | 313 | WRITE_FLAG( pcPPS->getUseWP() ? 1 : 0, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) |
---|
| 314 | WRITE_CODE( pcPPS->getWPBiPredIdc(), 2, "weighted_bipred_idc" ); // Use of Weighting Bi-Prediction (B_SLICE) |
---|
| 315 | #if H0388 |
---|
| 316 | WRITE_FLAG( pcPPS->getOutputFlagPresentFlag() ? 1 : 0, "output_flag_present_flag" ); |
---|
| 317 | #endif |
---|
| 318 | #if TILES_OR_ENTROPY_SYNC_IDC |
---|
| 319 | if(pcPPS->getSPS()->getTilesOrEntropyCodingSyncIdc()==1) |
---|
| 320 | { |
---|
| 321 | #endif |
---|
| 322 | WRITE_FLAG( pcPPS->getColumnRowInfoPresent(), "tile_info_present_flag" ); |
---|
| 323 | WRITE_FLAG( pcPPS->getTileBehaviorControlPresentFlag(), "tile_control_present_flag"); |
---|
| 324 | if( pcPPS->getColumnRowInfoPresent() == 1 ) |
---|
[2] | 325 | { |
---|
[56] | 326 | WRITE_UVLC( pcPPS->getNumColumnsMinus1(), "num_tile_columns_minus1" ); |
---|
| 327 | WRITE_UVLC( pcPPS->getNumRowsMinus1(), "num_tile_rows_minus1" ); |
---|
| 328 | WRITE_FLAG( pcPPS->getUniformSpacingIdr(), "uniform_spacing_flag" ); |
---|
| 329 | if( pcPPS->getUniformSpacingIdr() == 0 ) |
---|
[2] | 330 | { |
---|
[56] | 331 | for(UInt i=0; i<pcPPS->getNumColumnsMinus1(); i++) |
---|
[2] | 332 | { |
---|
[56] | 333 | WRITE_UVLC( pcPPS->getColumnWidth(i), "column_width" ); |
---|
[2] | 334 | } |
---|
[56] | 335 | for(UInt i=0; i<pcPPS->getNumRowsMinus1(); i++) |
---|
[2] | 336 | { |
---|
[56] | 337 | WRITE_UVLC( pcPPS->getRowHeight(i), "row_height" ); |
---|
[2] | 338 | } |
---|
| 339 | } |
---|
[56] | 340 | } |
---|
[2] | 341 | |
---|
[56] | 342 | if(pcPPS->getTileBehaviorControlPresentFlag() == 1) |
---|
[2] | 343 | { |
---|
[56] | 344 | Int iNumColTilesMinus1 = (pcPPS->getColumnRowInfoPresent() == 1)?(pcPPS->getNumColumnsMinus1()):(pcPPS->getSPS()->getNumColumnsMinus1()); |
---|
| 345 | Int iNumRowTilesMinus1 = (pcPPS->getColumnRowInfoPresent() == 1)?(pcPPS->getNumColumnsMinus1()):(pcPPS->getSPS()->getNumRowsMinus1()); |
---|
[2] | 346 | |
---|
[56] | 347 | if(iNumColTilesMinus1 !=0 || iNumRowTilesMinus1 !=0) |
---|
[2] | 348 | { |
---|
[56] | 349 | #if !REMOVE_TILE_DEPENDENCE |
---|
| 350 | WRITE_FLAG( pcPPS->getTileBoundaryIndependenceIdr(), "tile_boundary_independence_flag" ); |
---|
| 351 | if(pcPPS->getTileBoundaryIndependenceIdr() == 1) |
---|
[2] | 352 | { |
---|
[56] | 353 | #endif |
---|
| 354 | WRITE_FLAG( pcPPS->getLFCrossTileBoundaryFlag()?1 : 0, "loop_filter_across_tile_flag"); |
---|
| 355 | #if !REMOVE_TILE_DEPENDENCE |
---|
[2] | 356 | } |
---|
| 357 | #endif |
---|
| 358 | } |
---|
| 359 | } |
---|
[56] | 360 | #if TILES_OR_ENTROPY_SYNC_IDC |
---|
[2] | 361 | } |
---|
[56] | 362 | else if(pcPPS->getSPS()->getTilesOrEntropyCodingSyncIdc()==2) |
---|
[2] | 363 | { |
---|
[56] | 364 | WRITE_UVLC( pcPPS->getNumSubstreams()-1, "num_substreams_minus1" ); |
---|
[2] | 365 | } |
---|
| 366 | #endif |
---|
| 367 | |
---|
[56] | 368 | #if DBL_CONTROL |
---|
| 369 | WRITE_FLAG( pcPPS->getDeblockingFilterControlPresent()?1 : 0, "deblocking_filter_control_present_flag"); |
---|
[2] | 370 | #endif |
---|
[56] | 371 | #if PARALLEL_MERGE |
---|
| 372 | WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2"); |
---|
[2] | 373 | #endif |
---|
[56] | 374 | WRITE_FLAG( 0, "pps_extension_flag" ); |
---|
[2] | 375 | } |
---|
| 376 | |
---|
[213] | 377 | #if QC_MVHEVC_B0046 |
---|
| 378 | Void TEncCavlc::codeVPS( TComVPS* pcVPS ) |
---|
| 379 | { |
---|
| 380 | WRITE_CODE( pcVPS->getVPSId(), 4, "video_parameter_set_id" ); |
---|
| 381 | WRITE_FLAG( pcVPS->getTemporalNestingFlag() -1, "temporal_id_nesting_flag" ); |
---|
| 382 | WRITE_CODE( 0, 2, "vps_reserved_zero_2bits" ); |
---|
| 383 | WRITE_CODE( pcVPS->getMaxLayers() - 1, 6, "vps_max_layers_minus1" ); |
---|
| 384 | WRITE_CODE( pcVPS->getMaxTLayers() - 1, 3, "vps_max_sub_layers_minus1" ); |
---|
| 385 | //to be determined |
---|
| 386 | //profile_tier_level( 1, vps_max_sub_layers_minus1 ); |
---|
| 387 | //to be modified |
---|
| 388 | WRITE_CODE( 0, 12, "vps_extension_offset" ); |
---|
| 389 | for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
| 390 | { |
---|
| 391 | WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i), "max_dec_pic_buffering[i]" ); |
---|
| 392 | WRITE_UVLC( pcVPS->getNumReorderPics(i), "num_reorder_pics[i]" ); |
---|
| 393 | WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i), "max_latency_increase[i]" ); |
---|
| 394 | } |
---|
| 395 | //!!!waste one bit: 3-view, 3; 2-view or more views: 1 |
---|
| 396 | WRITE_UVLC(pcVPS->getNumHRDParameters(), "vps_num_hrd_parameters" ); |
---|
| 397 | assert(pcVPS->getNumHRDParameters()==0); |
---|
| 398 | for ( UInt i = 0; i < pcVPS->getNumHRDParameters(); i ++) |
---|
| 399 | { |
---|
| 400 | // if( i > 0 ) |
---|
| 401 | //{ |
---|
| 402 | // WRITE_UVLC (0, "op_num_layer_id_values_minus1[ opIdx ]"); |
---|
| 403 | // for( i = 0; i <= op_num_layer_id_values_minus1[ opIdx ]; i++ ) |
---|
| 404 | // WRITE_CODE(0, 6, "op_layer_id[ opIdx ][ i ]"); |
---|
| 405 | //} |
---|
| 406 | //hrd_parameters( i = = 0, vps_max_sub_layers_minus1 ); |
---|
| 407 | } |
---|
| 408 | WRITE_CODE( 1, 1, "bit_equal_to_one" ); |
---|
| 409 | //btye aligned |
---|
| 410 | m_pcBitIf->writeAlignOne(); |
---|
| 411 | |
---|
| 412 | if(pcVPS->getMaxLayers() == 3) |
---|
| 413 | pcVPS->setNumAddiLayerOperationPoints (pcVPS->getMaxLayers()); //may be configured |
---|
| 414 | else |
---|
| 415 | pcVPS->setNumAddiLayerOperationPoints (1); |
---|
| 416 | pcVPS->setNumAddiProLevelSets (1); |
---|
| 417 | WRITE_CODE( pcVPS->getNumAddiLayerOperationPoints(), 8, "num_additional_layer_operation_points" ); |
---|
| 418 | WRITE_CODE( pcVPS->getNumAddiProLevelSets(), 8, "num_additional_profile_level_sets" ); |
---|
| 419 | for(UInt i=0; i <= pcVPS->getMaxLayers()-1; i++) |
---|
| 420 | { |
---|
| 421 | WRITE_CODE( 0, 4, "num_types_zero_4bits[i]" ); |
---|
| 422 | WRITE_CODE( 0, 4, "type_zero_4bits[i]" ); |
---|
| 423 | WRITE_CODE( pcVPS->getViewId(i), 8, "view_id[i]" ); |
---|
| 424 | if(i) |
---|
| 425 | { |
---|
| 426 | WRITE_CODE( pcVPS->getNumDirectRefLayer(i), 6, "num_direct_ref_layers[ i ]" ); |
---|
| 427 | for (UInt j = 0; j< pcVPS->getNumDirectRefLayer(i); j++) |
---|
| 428 | { |
---|
| 429 | WRITE_CODE( pcVPS->getDirectRefLayerId (i, j), 6, "ref_layer_id[i][j]" ); |
---|
| 430 | } |
---|
| 431 | } |
---|
| 432 | } |
---|
| 433 | for( UInt i=1; i<=pcVPS->getNumAddiProLevelSets(); i++) |
---|
| 434 | { |
---|
| 435 | //profile_tier_level |
---|
| 436 | } |
---|
| 437 | for( UInt i=1; i<= pcVPS->getNumAddiLayerOperationPoints(); i++) |
---|
| 438 | { |
---|
| 439 | if(pcVPS->getMaxLayers() == 3) |
---|
| 440 | { |
---|
| 441 | pcVPS->setNumOpLayerIdMinus1((i < pcVPS->getNumAddiLayerOperationPoints() ? 1: 2), (i-1)); |
---|
| 442 | } |
---|
| 443 | else if( i==1 ) |
---|
| 444 | { |
---|
| 445 | assert(pcVPS->getNumAddiLayerOperationPoints()==1); |
---|
| 446 | pcVPS->setNumOpLayerIdMinus1(pcVPS->getMaxLayers()-1, (i-1)); |
---|
| 447 | } |
---|
| 448 | WRITE_UVLC( pcVPS->getNumOpLayerIdMinus1(i-1), "op_num_layer_id_values_minus1[ opIdx ]" ); |
---|
| 449 | for(UInt j = 0; j <= pcVPS->getNumOpLayerIdMinus1(i-1); j++ ) |
---|
| 450 | { |
---|
| 451 | if(pcVPS->getMaxLayers() == 3 && i== 2 && j==1) |
---|
| 452 | pcVPS->setNumOpLayerId (2, i-1, j); |
---|
| 453 | else |
---|
| 454 | pcVPS->setNumOpLayerId (j, i-1, j); |
---|
| 455 | WRITE_UVLC( pcVPS->getNumOpLayerId(i-1, j), "op_layer_id[ opIdx ][ i ]" ); |
---|
| 456 | } |
---|
| 457 | if (pcVPS->getNumAddiProLevelSets()) |
---|
| 458 | { |
---|
| 459 | //profile_level_idx[ i ] |
---|
| 460 | } |
---|
| 461 | } |
---|
| 462 | return; |
---|
| 463 | } |
---|
| 464 | #else |
---|
[77] | 465 | #if VIDYO_VPS_INTEGRATION |
---|
| 466 | Void TEncCavlc::codeVPS( TComVPS* pcVPS ) |
---|
| 467 | { |
---|
[100] | 468 | WRITE_CODE( pcVPS->getMaxTLayers() - 1, 3, "max_temporal_layers_minus1" ); |
---|
[77] | 469 | WRITE_CODE( pcVPS->getMaxLayers() - 1, 5, "max_layers_minus1" ); |
---|
| 470 | WRITE_FLAG( pcVPS->getTemporalNestingFlag() - 1, "temporal_id_nesting_flag" ); |
---|
| 471 | WRITE_UVLC( pcVPS->getVPSId(), "video_parameter_set_id" ); |
---|
| 472 | for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
| 473 | { |
---|
| 474 | WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i), "max_dec_pic_buffering[i]" ); |
---|
| 475 | WRITE_UVLC( pcVPS->getNumReorderPics(i), "num_reorder_pics[i]" ); |
---|
| 476 | WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i), "max_latency_increase[i]" ); |
---|
| 477 | } |
---|
| 478 | |
---|
| 479 | WRITE_CODE( 1, 1, "bit_equal_to_one" ); |
---|
| 480 | |
---|
| 481 | if( pcVPS->getMaxLayers() - 1 > 0 ) |
---|
| 482 | { |
---|
| 483 | WRITE_UVLC( pcVPS->getExtensionType(), "extension_type" ); |
---|
| 484 | |
---|
| 485 | for(UInt i=1; i <= pcVPS->getMaxLayers()-1; i++) |
---|
| 486 | { |
---|
| 487 | WRITE_FLAG( pcVPS->getDependentFlag(i), "dependent_flag[i]" ); |
---|
| 488 | if( pcVPS->getDependentFlag(i) ) |
---|
| 489 | { |
---|
| 490 | WRITE_UVLC( i - pcVPS->getDependentLayer(i) - 1, "delta_reference_layer_id_minus1[i]" ); |
---|
| 491 | if( pcVPS->getExtensionType() == VPS_EXTENSION_TYPE_MULTI_VIEW ) |
---|
| 492 | { |
---|
| 493 | WRITE_UVLC( pcVPS->getViewId(i), "view_id[i]" ); |
---|
| 494 | WRITE_FLAG( pcVPS->getDepthFlag(i), "depth_flag[i]" ); |
---|
| 495 | WRITE_SVLC( pcVPS->getViewOrderIdx(i), "view_order_idx[i]" ); |
---|
| 496 | } |
---|
| 497 | |
---|
| 498 | } |
---|
| 499 | } |
---|
| 500 | } |
---|
| 501 | |
---|
| 502 | WRITE_FLAG( 0, "vps_extension_flag" ); |
---|
| 503 | |
---|
| 504 | //future extensions here.. |
---|
| 505 | |
---|
| 506 | return; |
---|
| 507 | } |
---|
| 508 | #endif |
---|
[213] | 509 | #endif |
---|
[56] | 510 | #if HHI_MPI |
---|
| 511 | Void TEncCavlc::codeSPS( TComSPS* pcSPS, Bool bIsDepth ) |
---|
[2] | 512 | #else |
---|
[56] | 513 | Void TEncCavlc::codeSPS( TComSPS* pcSPS ) |
---|
[2] | 514 | #endif |
---|
[56] | 515 | { |
---|
| 516 | #if ENC_DEC_TRACE |
---|
| 517 | xTraceSPSHeader (pcSPS); |
---|
[2] | 518 | #endif |
---|
[56] | 519 | WRITE_CODE( pcSPS->getProfileIdc (), 8, "profile_idc" ); |
---|
| 520 | WRITE_CODE( 0, 8, "reserved_zero_8bits" ); |
---|
| 521 | WRITE_CODE( pcSPS->getLevelIdc (), 8, "level_idc" ); |
---|
| 522 | WRITE_UVLC( pcSPS->getSPSId (), "seq_parameter_set_id" ); |
---|
[77] | 523 | #if VIDYO_VPS_INTEGRATION |
---|
| 524 | WRITE_UVLC( pcSPS->getVPSId (), "video_parameter_set_id" ); |
---|
| 525 | #endif |
---|
[56] | 526 | WRITE_UVLC( pcSPS->getChromaFormatIdc (), "chroma_format_idc" ); |
---|
| 527 | WRITE_CODE( pcSPS->getMaxTLayers() - 1, 3, "max_temporal_layers_minus1" ); |
---|
| 528 | WRITE_UVLC( pcSPS->getPicWidthInLumaSamples (), "pic_width_in_luma_samples" ); |
---|
| 529 | WRITE_UVLC( pcSPS->getPicHeightInLumaSamples(), "pic_height_in_luma_samples" ); |
---|
| 530 | #if PIC_CROPPING |
---|
| 531 | WRITE_FLAG( pcSPS->getPicCroppingFlag(), "pic_cropping_flag" ); |
---|
| 532 | if (pcSPS->getPicCroppingFlag()) |
---|
[2] | 533 | { |
---|
[56] | 534 | WRITE_UVLC( pcSPS->getPicCropLeftOffset(), "pic_crop_left_offset" ); |
---|
| 535 | WRITE_UVLC( pcSPS->getPicCropRightOffset(), "pic_crop_right_offset" ); |
---|
| 536 | WRITE_UVLC( pcSPS->getPicCropTopOffset(), "pic_crop_top_offset" ); |
---|
| 537 | WRITE_UVLC( pcSPS->getPicCropBottomOffset(), "pic_crop_bottom_offset" ); |
---|
[2] | 538 | } |
---|
| 539 | #endif |
---|
| 540 | |
---|
[56] | 541 | #if FULL_NBIT |
---|
| 542 | WRITE_UVLC( pcSPS->getBitDepth() - 8, "bit_depth_luma_minus8" ); |
---|
[2] | 543 | #else |
---|
[56] | 544 | WRITE_UVLC( pcSPS->getBitIncrement(), "bit_depth_luma_minus8" ); |
---|
[2] | 545 | #endif |
---|
[56] | 546 | #if FULL_NBIT |
---|
| 547 | WRITE_UVLC( pcSPS->getBitDepth() - 8, "bit_depth_chroma_minus8" ); |
---|
| 548 | #else |
---|
| 549 | WRITE_UVLC( pcSPS->getBitIncrement(), "bit_depth_chroma_minus8" ); |
---|
[2] | 550 | #endif |
---|
| 551 | |
---|
[56] | 552 | WRITE_FLAG( pcSPS->getUsePCM() ? 1 : 0, "pcm_enabled_flag"); |
---|
[2] | 553 | |
---|
[56] | 554 | if( pcSPS->getUsePCM() ) |
---|
[2] | 555 | { |
---|
[56] | 556 | WRITE_CODE( pcSPS->getPCMBitDepthLuma() - 1, 4, "pcm_bit_depth_luma_minus1" ); |
---|
| 557 | WRITE_CODE( pcSPS->getPCMBitDepthChroma() - 1, 4, "pcm_bit_depth_chroma_minus1" ); |
---|
[2] | 558 | } |
---|
[56] | 559 | |
---|
| 560 | #if LOSSLESS_CODING |
---|
| 561 | WRITE_FLAG( (pcSPS->getUseLossless ()) ? 1 : 0, "qpprime_y_zero_transquant_bypass_flag" ); |
---|
[2] | 562 | #endif |
---|
[56] | 563 | |
---|
| 564 | WRITE_UVLC( pcSPS->getBitsForPOC()-4, "log2_max_pic_order_cnt_lsb_minus4" ); |
---|
| 565 | #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
| 566 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
[2] | 567 | { |
---|
[56] | 568 | WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i), "max_dec_pic_buffering[i]" ); |
---|
| 569 | WRITE_UVLC( pcSPS->getNumReorderPics(i), "num_reorder_pics[i]" ); |
---|
| 570 | WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i), "max_latency_increase[i]" ); |
---|
[2] | 571 | } |
---|
| 572 | #else |
---|
[56] | 573 | WRITE_UVLC( pcSPS->getMaxNumberOfReferencePictures(), "max_num_ref_pics" ); |
---|
| 574 | WRITE_UVLC( pcSPS->getNumReorderFrames(), "num_reorder_frames" ); |
---|
| 575 | WRITE_UVLC(pcSPS->getMaxDecFrameBuffering(), "max_dec_frame_buffering" ); |
---|
| 576 | WRITE_UVLC(pcSPS->getMaxLatencyIncrease(), "max_latency_increase" ); |
---|
[2] | 577 | #endif |
---|
[56] | 578 | assert( pcSPS->getMaxCUWidth() == pcSPS->getMaxCUHeight() ); |
---|
| 579 | |
---|
| 580 | UInt MinCUSize = pcSPS->getMaxCUWidth() >> ( pcSPS->getMaxCUDepth()-g_uiAddCUDepth ); |
---|
| 581 | UInt log2MinCUSize = 0; |
---|
| 582 | while(MinCUSize > 1) |
---|
[2] | 583 | { |
---|
[56] | 584 | MinCUSize >>= 1; |
---|
| 585 | log2MinCUSize++; |
---|
[2] | 586 | } |
---|
| 587 | |
---|
[56] | 588 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
| 589 | WRITE_FLAG( pcSPS->getRestrictedRefPicListsFlag(), "restricted_ref_pic_lists_flag" ); |
---|
| 590 | if( pcSPS->getRestrictedRefPicListsFlag() ) |
---|
[2] | 591 | { |
---|
[56] | 592 | WRITE_FLAG( pcSPS->getListsModificationPresentFlag(), "lists_modification_present_flag" ); |
---|
[2] | 593 | } |
---|
[5] | 594 | #endif |
---|
[56] | 595 | WRITE_UVLC( log2MinCUSize - 3, "log2_min_coding_block_size_minus3" ); |
---|
| 596 | WRITE_UVLC( pcSPS->getMaxCUDepth()-g_uiAddCUDepth, "log2_diff_max_min_coding_block_size" ); |
---|
| 597 | WRITE_UVLC( pcSPS->getQuadtreeTULog2MinSize() - 2, "log2_min_transform_block_size_minus2" ); |
---|
| 598 | WRITE_UVLC( pcSPS->getQuadtreeTULog2MaxSize() - pcSPS->getQuadtreeTULog2MinSize(), "log2_diff_max_min_transform_block_size" ); |
---|
[2] | 599 | |
---|
[56] | 600 | if(log2MinCUSize == 3) |
---|
[2] | 601 | { |
---|
[56] | 602 | xWriteFlag ( (pcSPS->getDisInter4x4()) ? 1 : 0 ); |
---|
[2] | 603 | } |
---|
| 604 | |
---|
[56] | 605 | if( pcSPS->getUsePCM() ) |
---|
[2] | 606 | { |
---|
[56] | 607 | WRITE_UVLC( pcSPS->getPCMLog2MinSize() - 3, "log2_min_pcm_coding_block_size_minus3" ); |
---|
| 608 | WRITE_UVLC( pcSPS->getPCMLog2MaxSize() - pcSPS->getPCMLog2MinSize(), "log2_diff_max_min_pcm_coding_block_size" ); |
---|
[2] | 609 | } |
---|
[56] | 610 | WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthInter() - 1, "max_transform_hierarchy_depth_inter" ); |
---|
| 611 | WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthIntra() - 1, "max_transform_hierarchy_depth_intra" ); |
---|
| 612 | WRITE_FLAG( pcSPS->getScalingListFlag() ? 1 : 0, "scaling_list_enabled_flag" ); |
---|
| 613 | WRITE_FLAG( pcSPS->getUseLMChroma () ? 1 : 0, "chroma_pred_from_luma_enabled_flag" ); |
---|
| 614 | WRITE_FLAG( pcSPS->getUseDF() ? 1 : 0, "deblocking_filter_in_aps_enabled_flag"); |
---|
| 615 | WRITE_FLAG( pcSPS->getLFCrossSliceBoundaryFlag()?1 : 0, "seq_loop_filter_across_slices_enabled_flag"); |
---|
| 616 | WRITE_FLAG( pcSPS->getUseAMP(), "asymmetric_motion_partitions_enabled_flag" ); |
---|
| 617 | WRITE_FLAG( pcSPS->getUseNSQT(), "non_square_quadtree_enabled_flag" ); |
---|
| 618 | WRITE_FLAG( pcSPS->getUseSAO() ? 1 : 0, "sample_adaptive_offset_enabled_flag"); |
---|
| 619 | WRITE_FLAG( pcSPS->getUseALF () ? 1 : 0, "adaptive_loop_filter_enabled_flag"); |
---|
| 620 | #if LCU_SYNTAX_ALF |
---|
| 621 | if(pcSPS->getUseALF()) |
---|
[2] | 622 | { |
---|
[56] | 623 | WRITE_FLAG( (pcSPS->getUseALFCoefInSlice()) ? 1 : 0, "alf_coef_in_slice_flag"); |
---|
[2] | 624 | } |
---|
| 625 | #endif |
---|
| 626 | |
---|
[56] | 627 | if( pcSPS->getUsePCM() ) |
---|
[2] | 628 | { |
---|
[56] | 629 | WRITE_FLAG( pcSPS->getPCMFilterDisableFlag()?1 : 0, "pcm_loop_filter_disable_flag"); |
---|
[2] | 630 | } |
---|
| 631 | |
---|
[56] | 632 | assert( pcSPS->getMaxTLayers() > 0 ); |
---|
[2] | 633 | |
---|
[56] | 634 | WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0, "temporal_id_nesting_flag" ); |
---|
[2] | 635 | |
---|
[56] | 636 | #if RPS_IN_SPS |
---|
| 637 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
| 638 | TComReferencePictureSet* rps; |
---|
[2] | 639 | |
---|
[56] | 640 | WRITE_UVLC(rpsList->getNumberOfReferencePictureSets(), "num_short_term_ref_pic_sets" ); |
---|
| 641 | for(Int i=0; i < rpsList->getNumberOfReferencePictureSets(); i++) |
---|
[2] | 642 | { |
---|
[56] | 643 | rps = rpsList->getReferencePictureSet(i); |
---|
| 644 | codeShortTermRefPicSet(pcSPS,rps); |
---|
| 645 | } |
---|
| 646 | WRITE_FLAG( pcSPS->getLongTermRefsPresent() ? 1 : 0, "long_term_ref_pics_present_flag" ); |
---|
[2] | 647 | #endif |
---|
[56] | 648 | #if !PIC_CROPPING |
---|
| 649 | //!!!KS: Syntax not in WD !!! |
---|
| 650 | |
---|
| 651 | xWriteUvlc ( pcSPS->getPad (0) ); |
---|
| 652 | xWriteUvlc ( pcSPS->getPad (1) ); |
---|
| 653 | #endif |
---|
| 654 | // AMVP mode for each depth |
---|
| 655 | for (Int i = 0; i < pcSPS->getMaxCUDepth(); i++) |
---|
[2] | 656 | { |
---|
[56] | 657 | xWriteFlag( pcSPS->getAMVPMode(i) ? 1 : 0); |
---|
[2] | 658 | } |
---|
| 659 | |
---|
[56] | 660 | #if TILES_WPP_ENTRY_POINT_SIGNALLING |
---|
| 661 | Int tilesOrEntropyCodingSyncIdc = 0; |
---|
| 662 | if ( pcSPS->getNumColumnsMinus1() > 0 || pcSPS->getNumRowsMinus1() > 0) |
---|
[2] | 663 | { |
---|
[56] | 664 | tilesOrEntropyCodingSyncIdc = 1; |
---|
[2] | 665 | } |
---|
[56] | 666 | else if ( pcSPS->getNumSubstreams() > 1 ) |
---|
[2] | 667 | { |
---|
[56] | 668 | tilesOrEntropyCodingSyncIdc = 2; |
---|
[2] | 669 | } |
---|
[56] | 670 | pcSPS->setTilesOrEntropyCodingSyncIdc( tilesOrEntropyCodingSyncIdc ); |
---|
| 671 | WRITE_CODE(tilesOrEntropyCodingSyncIdc, 2, "tiles_or_entropy_coding_sync_idc"); |
---|
[2] | 672 | #endif |
---|
[56] | 673 | |
---|
| 674 | #if TILES_OR_ENTROPY_SYNC_IDC |
---|
| 675 | if(tilesOrEntropyCodingSyncIdc == 1) |
---|
[2] | 676 | { |
---|
| 677 | #endif |
---|
[56] | 678 | WRITE_UVLC( pcSPS->getNumColumnsMinus1(), "num_tile_columns_minus1" ); |
---|
| 679 | WRITE_UVLC( pcSPS->getNumRowsMinus1(), "num_tile_rows_minus1" ); |
---|
| 680 | WRITE_FLAG( pcSPS->getUniformSpacingIdr(), "uniform_spacing_flag" ); |
---|
[2] | 681 | |
---|
[56] | 682 | if( pcSPS->getUniformSpacingIdr()==0 ) |
---|
[2] | 683 | { |
---|
[56] | 684 | for(UInt i=0; i<pcSPS->getNumColumnsMinus1(); i++) |
---|
[2] | 685 | { |
---|
[56] | 686 | WRITE_UVLC( pcSPS->getColumnWidth(i), "column_width" ); |
---|
[2] | 687 | } |
---|
[56] | 688 | for(UInt i=0; i<pcSPS->getNumRowsMinus1(); i++) |
---|
[2] | 689 | { |
---|
[56] | 690 | WRITE_UVLC( pcSPS->getRowHeight(i), "row_height" ); |
---|
[2] | 691 | } |
---|
| 692 | } |
---|
[56] | 693 | |
---|
| 694 | if( pcSPS->getNumColumnsMinus1() !=0 || pcSPS->getNumRowsMinus1() != 0) |
---|
[2] | 695 | { |
---|
[56] | 696 | #if !REMOVE_TILE_DEPENDENCE |
---|
| 697 | WRITE_FLAG( pcSPS->getTileBoundaryIndependenceIdr(), "tile_boundary_independence_flag" ); |
---|
| 698 | if(pcSPS->getTileBoundaryIndependenceIdr() == 1) |
---|
[2] | 699 | { |
---|
[56] | 700 | #endif |
---|
| 701 | WRITE_FLAG( pcSPS->getLFCrossTileBoundaryFlag()?1 : 0, "loop_filter_across_tile_flag"); |
---|
| 702 | #if !REMOVE_TILE_DEPENDENCE |
---|
[2] | 703 | } |
---|
[56] | 704 | #endif |
---|
[2] | 705 | } |
---|
[56] | 706 | #if TILES_OR_ENTROPY_SYNC_IDC |
---|
[2] | 707 | } |
---|
[56] | 708 | #endif |
---|
| 709 | WRITE_FLAG( 1, "sps_extension_flag" ); |
---|
[213] | 710 | #if !QC_MVHEVC_B0046 |
---|
[56] | 711 | WRITE_FLAG( (pcSPS->getNumberOfUsableInterViewRefs() > 0) ? 1 : 0, "interview_refs_present_flag" ); |
---|
| 712 | if( pcSPS->getNumberOfUsableInterViewRefs() > 0 ) |
---|
[2] | 713 | { |
---|
[56] | 714 | WRITE_UVLC( pcSPS->getNumberOfUsableInterViewRefs() - 1, "num_usable_interview_refs_minus1" ); |
---|
| 715 | |
---|
| 716 | Int prev = 0; |
---|
| 717 | for( Int j = 0 ; j < pcSPS->getNumberOfUsableInterViewRefs(); j++ ) |
---|
| 718 | { |
---|
| 719 | WRITE_UVLC( prev - pcSPS->getUsableInterViewRef( j ) - 1, "delta_usable_interview_ref_minus1" ); |
---|
| 720 | prev = pcSPS->getUsableInterViewRef( j ); |
---|
| 721 | } |
---|
[2] | 722 | } |
---|
| 723 | |
---|
[56] | 724 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
| 725 | WRITE_FLAG( pcSPS->getUseDMM(), "enable_dmm_flag" ); |
---|
[2] | 726 | #endif |
---|
| 727 | |
---|
[56] | 728 | #if HHI_MPI |
---|
| 729 | if( bIsDepth ) |
---|
[2] | 730 | { |
---|
[56] | 731 | WRITE_FLAG( pcSPS->getUseMVI() ? 1 : 0, "use_mvi_flag" ); |
---|
[2] | 732 | } |
---|
| 733 | #endif |
---|
| 734 | |
---|
[213] | 735 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
| 736 | if( bIsDepth ) |
---|
| 737 | { |
---|
| 738 | WRITE_FLAG( pcSPS->getUseQTLPC() ? 1 : 0, "use_qtlpc_flag"); |
---|
| 739 | } |
---|
| 740 | #endif |
---|
| 741 | |
---|
| 742 | #if RWTH_SDC_DLT_B0036 |
---|
| 743 | if( bIsDepth ) |
---|
| 744 | { |
---|
| 745 | WRITE_FLAG( pcSPS->getUseDLT() ? 1 : 0, "use_dlt_flag" ); |
---|
| 746 | if( pcSPS->getUseDLT() ) |
---|
| 747 | { |
---|
| 748 | // code mapping |
---|
| 749 | xWriteUvlc ( pcSPS->getNumDepthValues() ); |
---|
| 750 | for(UInt i=0; i<pcSPS->getNumDepthValues(); i++) |
---|
| 751 | { |
---|
| 752 | xWriteUvlc( pcSPS->idx2DepthValue(i) ); |
---|
| 753 | } |
---|
| 754 | } |
---|
| 755 | } |
---|
| 756 | #endif |
---|
| 757 | |
---|
[56] | 758 | if( pcSPS->getViewId() || pcSPS->isDepth() ) |
---|
[2] | 759 | { |
---|
[56] | 760 | WRITE_FLAG( 0, "base_view_flag" ); |
---|
| 761 | if( pcSPS->isDepth() ) |
---|
[2] | 762 | { |
---|
[56] | 763 | WRITE_FLAG( 1, "depth_flag" ); |
---|
| 764 | WRITE_UVLC( pcSPS->getViewId(), "view_id" ); |
---|
| 765 | WRITE_SVLC( pcSPS->getViewOrderIdx(), "view_order_idx" ); |
---|
[213] | 766 | #if VSP_N |
---|
| 767 | if( pcSPS->getViewId() ) |
---|
| 768 | { |
---|
| 769 | WRITE_FLAG( pcSPS->getIsFirstInView() ? 1 : 0, "camera_parameter_present_flag" ); |
---|
| 770 | if( pcSPS->getIsFirstInView() ) |
---|
| 771 | { |
---|
| 772 | WRITE_UVLC( pcSPS->getCamParPrecision(), "camera_parameter_precision" ); |
---|
| 773 | WRITE_FLAG( pcSPS->hasCamParInSliceHeader() ? 1 : 0, "camera_parameter_in_slice_header" ); |
---|
| 774 | if( !pcSPS->hasCamParInSliceHeader() ) |
---|
| 775 | { |
---|
| 776 | for( UInt uiId = 0; uiId < pcSPS->getViewId(); uiId++ ) |
---|
| 777 | { |
---|
| 778 | WRITE_SVLC( pcSPS->getCodedScale ()[ uiId ], "coded_scale" ); |
---|
| 779 | WRITE_SVLC( pcSPS->getCodedOffset ()[ uiId ], "coded_offset" ); |
---|
| 780 | WRITE_SVLC( pcSPS->getInvCodedScale ()[ uiId ] + pcSPS->getCodedScale ()[ uiId ], "inverse_coded_scale_plus_coded_scale" ); |
---|
| 781 | WRITE_SVLC( pcSPS->getInvCodedOffset()[ uiId ] + pcSPS->getCodedOffset()[ uiId ], "inverse_coded_offset_plus_coded_offset" ); |
---|
| 782 | } |
---|
| 783 | } |
---|
| 784 | } |
---|
| 785 | } |
---|
| 786 | #endif |
---|
[2] | 787 | } |
---|
| 788 | else |
---|
| 789 | { |
---|
[56] | 790 | WRITE_FLAG( 0, "depth_flag" ); |
---|
| 791 | WRITE_UVLC( pcSPS->getViewId() - 1, "view_id_minus1" ); |
---|
| 792 | WRITE_SVLC( pcSPS->getViewOrderIdx(), "view_order_idx" ); |
---|
[213] | 793 | #if VSP_N |
---|
| 794 | WRITE_FLAG( pcSPS->getIsFirstInView() ? 1 : 0, "camera_parameter_present_flag" ); |
---|
| 795 | if( pcSPS->getIsFirstInView() ) |
---|
| 796 | { |
---|
| 797 | #endif |
---|
[56] | 798 | WRITE_UVLC( pcSPS->getCamParPrecision(), "camera_parameter_precision" ); |
---|
| 799 | WRITE_FLAG( pcSPS->hasCamParInSliceHeader() ? 1 : 0, "camera_parameter_in_slice_header" ); |
---|
| 800 | if( !pcSPS->hasCamParInSliceHeader() ) |
---|
| 801 | { |
---|
| 802 | for( UInt uiId = 0; uiId < pcSPS->getViewId(); uiId++ ) |
---|
| 803 | { |
---|
| 804 | WRITE_SVLC( pcSPS->getCodedScale ()[ uiId ], "coded_scale" ); |
---|
| 805 | WRITE_SVLC( pcSPS->getCodedOffset ()[ uiId ], "coded_offset" ); |
---|
| 806 | WRITE_SVLC( pcSPS->getInvCodedScale ()[ uiId ] + pcSPS->getCodedScale ()[ uiId ], "inverse_coded_scale_plus_coded_scale" ); |
---|
| 807 | WRITE_SVLC( pcSPS->getInvCodedOffset()[ uiId ] + pcSPS->getCodedOffset()[ uiId ], "inverse_coded_offset_plus_coded_offset" ); |
---|
| 808 | } |
---|
[2] | 809 | } |
---|
[213] | 810 | #if VSP_N |
---|
| 811 | } |
---|
| 812 | #endif |
---|
[56] | 813 | #if DEPTH_MAP_GENERATION |
---|
| 814 | WRITE_UVLC( pcSPS->getPredDepthMapGeneration(), "Pdm_generation" ); |
---|
| 815 | if( pcSPS->getPredDepthMapGeneration() ) |
---|
[2] | 816 | { |
---|
[56] | 817 | WRITE_UVLC( pcSPS->getPdmPrecision(), "Pdm_precision" ); |
---|
| 818 | for( UInt uiId = 0; uiId < pcSPS->getViewId(); uiId++ ) |
---|
| 819 | { |
---|
| 820 | WRITE_SVLC( pcSPS->getPdmScaleNomDelta()[ uiId ], "Pdm_scale_nom_delta" ); |
---|
| 821 | WRITE_SVLC( pcSPS->getPdmOffset ()[ uiId ], "Pdm_offset" ); |
---|
| 822 | } |
---|
| 823 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
| 824 | WRITE_UVLC( pcSPS->getMultiviewMvPredMode(), "multi_view_mv_pred_mode" ); |
---|
| 825 | #endif |
---|
| 826 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 827 | WRITE_FLAG ( pcSPS->getMultiviewResPredMode(), "multi_view_residual_pred_mode" ); |
---|
| 828 | #endif |
---|
[2] | 829 | } |
---|
[56] | 830 | #endif |
---|
[2] | 831 | } |
---|
| 832 | } |
---|
[56] | 833 | else |
---|
[2] | 834 | { |
---|
[56] | 835 | WRITE_FLAG( 1, "base_view_flag" ); |
---|
[2] | 836 | } |
---|
[193] | 837 | #if VSP_N |
---|
| 838 | if( pcSPS->getViewId() ) |
---|
| 839 | { |
---|
| 840 | WRITE_FLAG( pcSPS->getVspPresentFlag(), "vsp_present_flag" ); |
---|
| 841 | #if VSP_CFG |
---|
| 842 | if( pcSPS->getVspPresentFlag() ) |
---|
| 843 | { |
---|
| 844 | WRITE_FLAG( pcSPS->getVspDepthPresentFlag(), "vsp_depth_present_flag" ); |
---|
| 845 | } |
---|
| 846 | #endif |
---|
| 847 | } |
---|
| 848 | #endif |
---|
[56] | 849 | WRITE_FLAG( 0, "sps_extension2_flag" ); |
---|
[213] | 850 | #endif |
---|
[56] | 851 | } |
---|
[2] | 852 | |
---|
[56] | 853 | Void TEncCavlc::writeTileMarker( UInt uiTileIdx, UInt uiBitsUsed ) |
---|
| 854 | { |
---|
| 855 | xWriteCode( uiTileIdx, uiBitsUsed ); |
---|
[2] | 856 | } |
---|
| 857 | |
---|
[56] | 858 | Void TEncCavlc::codeSliceHeader ( TComSlice* pcSlice ) |
---|
[2] | 859 | { |
---|
[56] | 860 | #if ENC_DEC_TRACE |
---|
| 861 | xTraceSliceHeader (pcSlice); |
---|
[2] | 862 | #endif |
---|
| 863 | |
---|
[193] | 864 | #if VSP_CFG |
---|
| 865 | Int iNumOfVspRefsL0 = 0; |
---|
| 866 | Int iNumOfVspRefsL1 = 0; |
---|
| 867 | #endif |
---|
| 868 | |
---|
[56] | 869 | // if( nal_ref_idc != 0 ) |
---|
| 870 | // dec_ref_pic_marking( ) |
---|
| 871 | // if( entropy_coding_mode_flag && slice_type != I) |
---|
| 872 | // cabac_init_idc |
---|
| 873 | // first_slice_in_pic_flag |
---|
| 874 | // if( first_slice_in_pic_flag == 0 ) |
---|
| 875 | // slice_address |
---|
| 876 | //calculate number of bits required for slice address |
---|
| 877 | Int maxAddrOuter = pcSlice->getPic()->getNumCUsInFrame(); |
---|
| 878 | Int reqBitsOuter = 0; |
---|
| 879 | while(maxAddrOuter>(1<<reqBitsOuter)) |
---|
[2] | 880 | { |
---|
[56] | 881 | reqBitsOuter++; |
---|
[2] | 882 | } |
---|
[56] | 883 | Int maxAddrInner = pcSlice->getPic()->getNumPartInCU()>>(2); |
---|
| 884 | maxAddrInner = (1<<(pcSlice->getPPS()->getSliceGranularity()<<1)); |
---|
| 885 | Int reqBitsInner = 0; |
---|
| 886 | |
---|
| 887 | while(maxAddrInner>(1<<reqBitsInner)) |
---|
[2] | 888 | { |
---|
[56] | 889 | reqBitsInner++; |
---|
[2] | 890 | } |
---|
[56] | 891 | Int lCUAddress; |
---|
| 892 | Int innerAddress; |
---|
| 893 | if (pcSlice->isNextSlice()) |
---|
[2] | 894 | { |
---|
[56] | 895 | // Calculate slice address |
---|
| 896 | lCUAddress = (pcSlice->getSliceCurStartCUAddr()/pcSlice->getPic()->getNumPartInCU()); |
---|
| 897 | innerAddress = (pcSlice->getSliceCurStartCUAddr()%(pcSlice->getPic()->getNumPartInCU()))>>((pcSlice->getSPS()->getMaxCUDepth()-pcSlice->getPPS()->getSliceGranularity())<<1); |
---|
[2] | 898 | } |
---|
| 899 | else |
---|
| 900 | { |
---|
[56] | 901 | // Calculate slice address |
---|
| 902 | lCUAddress = (pcSlice->getEntropySliceCurStartCUAddr()/pcSlice->getPic()->getNumPartInCU()); |
---|
| 903 | innerAddress = (pcSlice->getEntropySliceCurStartCUAddr()%(pcSlice->getPic()->getNumPartInCU()))>>((pcSlice->getSPS()->getMaxCUDepth()-pcSlice->getPPS()->getSliceGranularity())<<1); |
---|
| 904 | |
---|
[2] | 905 | } |
---|
[56] | 906 | //write slice address |
---|
| 907 | Int address = (pcSlice->getPic()->getPicSym()->getCUOrderMap(lCUAddress) << reqBitsInner) + innerAddress; |
---|
| 908 | WRITE_FLAG( address==0, "first_slice_in_pic_flag" ); |
---|
[213] | 909 | |
---|
| 910 | #if LGE_ILLUCOMP_B0045 |
---|
| 911 | // IC flag is on only first_slice_in_pic |
---|
| 912 | if (address==0) |
---|
| 913 | { |
---|
| 914 | if( pcSlice->getSPS()->getViewId() && !pcSlice->getIsDepth() ) |
---|
| 915 | { |
---|
| 916 | WRITE_FLAG( pcSlice->getApplyIC() ? 1 : 0, "applying IC flag" ); |
---|
| 917 | } |
---|
| 918 | } |
---|
| 919 | #endif |
---|
| 920 | |
---|
[56] | 921 | if(address>0) |
---|
[2] | 922 | { |
---|
[56] | 923 | WRITE_CODE( address, reqBitsOuter+reqBitsInner, "slice_address" ); |
---|
[2] | 924 | } |
---|
| 925 | |
---|
[56] | 926 | WRITE_UVLC( pcSlice->getSliceType(), "slice_type" ); |
---|
| 927 | Bool bEntropySlice = (!pcSlice->isNextSlice()); |
---|
| 928 | WRITE_FLAG( bEntropySlice ? 1 : 0, "lightweight_slice_flag" ); |
---|
| 929 | |
---|
| 930 | if (!bEntropySlice) |
---|
[2] | 931 | { |
---|
[213] | 932 | #if QC_MVHEVC_B0046 |
---|
| 933 | WRITE_UVLC( 0, "pic_parameter_set_id" ); |
---|
| 934 | #else |
---|
[56] | 935 | WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "pic_parameter_set_id" ); |
---|
[213] | 936 | #endif |
---|
[56] | 937 | #if H0388 |
---|
| 938 | if( pcSlice->getPPS()->getOutputFlagPresentFlag() ) |
---|
[2] | 939 | { |
---|
[56] | 940 | WRITE_FLAG( pcSlice->getPicOutputFlag() ? 1 : 0, "pic_output_flag" ); |
---|
[2] | 941 | } |
---|
| 942 | #endif |
---|
[213] | 943 | #if QC_REM_IDV_B0046 |
---|
| 944 | if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_IDR && pcSlice->getViewId() == 0) |
---|
| 945 | #else |
---|
[56] | 946 | if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_IDR) |
---|
[213] | 947 | #endif |
---|
[2] | 948 | { |
---|
[56] | 949 | WRITE_UVLC( 0, "idr_pic_id" ); |
---|
| 950 | WRITE_FLAG( 0, "no_output_of_prior_pics_flag" ); |
---|
[2] | 951 | } |
---|
| 952 | else |
---|
| 953 | { |
---|
[56] | 954 | WRITE_CODE( (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC()))%(1<<pcSlice->getSPS()->getBitsForPOC()), pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb"); |
---|
[213] | 955 | #if QC_REM_IDV_B0046 |
---|
| 956 | if( pcSlice->getPOC() == 0 && !(pcSlice->getSPS()->getViewId() && (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA))) |
---|
| 957 | #else |
---|
[77] | 958 | if( pcSlice->getPOC() == 0 && pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDV ) |
---|
[213] | 959 | #endif |
---|
[77] | 960 | { |
---|
| 961 | TComReferencePictureSet* rps = pcSlice->getRPS(); |
---|
| 962 | if(pcSlice->getRPSidx() < 0) |
---|
| 963 | { |
---|
| 964 | WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag"); |
---|
| 965 | #if RPS_IN_SPS |
---|
| 966 | codeShortTermRefPicSet(pcSlice->getSPS(), rps); |
---|
| 967 | #else |
---|
| 968 | codeShortTermRefPicSet(pcSlice->getPPS(), rps); |
---|
| 969 | #endif |
---|
| 970 | } |
---|
| 971 | else |
---|
| 972 | { |
---|
| 973 | WRITE_FLAG( 1, "short_term_ref_pic_set_sps_flag"); |
---|
| 974 | WRITE_UVLC( pcSlice->getRPSidx(), "short_term_ref_pic_set_idx" ); |
---|
| 975 | } |
---|
| 976 | #if RPS_IN_SPS |
---|
| 977 | if(pcSlice->getSPS()->getLongTermRefsPresent()) |
---|
| 978 | #else |
---|
| 979 | if(pcSlice->getPPS()->getLongTermRefsPresent()) |
---|
| 980 | #endif |
---|
| 981 | { |
---|
| 982 | WRITE_UVLC( rps->getNumberOfLongtermPictures(), "num_long_term_pics"); |
---|
| 983 | Int maxPocLsb = 1<<pcSlice->getSPS()->getBitsForPOC(); |
---|
| 984 | Int prev = 0; |
---|
| 985 | #if LTRP_MULT |
---|
| 986 | Int prevDeltaPocLt=0; |
---|
| 987 | Int currDeltaPocLt=0; |
---|
| 988 | #endif |
---|
| 989 | for(Int i=rps->getNumberOfPictures()-1 ; i > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; i--) |
---|
| 990 | { |
---|
| 991 | WRITE_UVLC((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb, "delta_poc_lsb_lt"); |
---|
| 992 | |
---|
| 993 | #if LTRP_MULT |
---|
| 994 | currDeltaPocLt=((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb)+prevDeltaPocLt; |
---|
[2] | 995 | |
---|
[77] | 996 | Int deltaMsbCycle=0; |
---|
| 997 | if( (i==(rps->getNumberOfPictures()-1)) ) |
---|
| 998 | { |
---|
| 999 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 1000 | } |
---|
| 1001 | else if( prevDeltaPocLt!=currDeltaPocLt ) |
---|
| 1002 | { |
---|
| 1003 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 1004 | if( ((prevDeltaPocLt==maxPocLsb-1) && (currDeltaPocLt==maxPocLsb+1)) || ((prevDeltaPocLt==maxPocLsb-2) && (currDeltaPocLt==maxPocLsb))) |
---|
| 1005 | { |
---|
| 1006 | deltaMsbCycle=deltaMsbCycle-1; |
---|
| 1007 | } |
---|
| 1008 | } |
---|
| 1009 | else |
---|
| 1010 | { |
---|
| 1011 | deltaMsbCycle=((rps->getDeltaPOC(i+1)-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 1012 | } |
---|
| 1013 | |
---|
| 1014 | if(deltaMsbCycle>=0) |
---|
| 1015 | { |
---|
| 1016 | WRITE_FLAG( 1, "delta_poc_msb_present_flag"); |
---|
| 1017 | WRITE_UVLC(deltaMsbCycle, "delta_poc_msb_cycle_lt_minus1"); |
---|
| 1018 | } |
---|
| 1019 | else |
---|
| 1020 | { |
---|
| 1021 | WRITE_FLAG( 0, "delta_poc_msb_present_flag"); |
---|
| 1022 | } |
---|
| 1023 | prevDeltaPocLt=currDeltaPocLt; |
---|
| 1024 | #endif |
---|
| 1025 | prev = rps->getDeltaPOC(i); |
---|
| 1026 | WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag"); |
---|
| 1027 | } |
---|
| 1028 | } |
---|
| 1029 | } |
---|
| 1030 | if( pcSlice->getPOC() != 0 ) |
---|
[2] | 1031 | { |
---|
[56] | 1032 | TComReferencePictureSet* rps = pcSlice->getRPS(); |
---|
| 1033 | if(pcSlice->getRPSidx() < 0) |
---|
| 1034 | { |
---|
| 1035 | WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag"); |
---|
| 1036 | #if RPS_IN_SPS |
---|
| 1037 | codeShortTermRefPicSet(pcSlice->getSPS(), rps); |
---|
| 1038 | #else |
---|
| 1039 | codeShortTermRefPicSet(pcSlice->getPPS(), rps); |
---|
[2] | 1040 | #endif |
---|
[56] | 1041 | } |
---|
| 1042 | else |
---|
[2] | 1043 | { |
---|
[56] | 1044 | WRITE_FLAG( 1, "short_term_ref_pic_set_sps_flag"); |
---|
| 1045 | WRITE_UVLC( pcSlice->getRPSidx(), "short_term_ref_pic_set_idx" ); |
---|
[2] | 1046 | } |
---|
[56] | 1047 | #if RPS_IN_SPS |
---|
| 1048 | if(pcSlice->getSPS()->getLongTermRefsPresent()) |
---|
| 1049 | #else |
---|
| 1050 | if(pcSlice->getPPS()->getLongTermRefsPresent()) |
---|
[2] | 1051 | #endif |
---|
| 1052 | { |
---|
[56] | 1053 | WRITE_UVLC( rps->getNumberOfLongtermPictures(), "num_long_term_pics"); |
---|
| 1054 | Int maxPocLsb = 1<<pcSlice->getSPS()->getBitsForPOC(); |
---|
| 1055 | Int prev = 0; |
---|
| 1056 | #if LTRP_MULT |
---|
| 1057 | Int prevDeltaPocLt=0; |
---|
| 1058 | Int currDeltaPocLt=0; |
---|
| 1059 | #endif |
---|
| 1060 | for(Int i=rps->getNumberOfPictures()-1 ; i > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; i--) |
---|
| 1061 | { |
---|
| 1062 | WRITE_UVLC((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb, "delta_poc_lsb_lt"); |
---|
| 1063 | |
---|
| 1064 | #if LTRP_MULT |
---|
| 1065 | currDeltaPocLt=((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb)+prevDeltaPocLt; |
---|
| 1066 | |
---|
| 1067 | Int deltaMsbCycle=0; |
---|
| 1068 | if( (i==(rps->getNumberOfPictures()-1)) ) |
---|
| 1069 | { |
---|
| 1070 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 1071 | } |
---|
| 1072 | else if( prevDeltaPocLt!=currDeltaPocLt ) |
---|
| 1073 | { |
---|
| 1074 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 1075 | if( ((prevDeltaPocLt==maxPocLsb-1) && (currDeltaPocLt==maxPocLsb+1)) || ((prevDeltaPocLt==maxPocLsb-2) && (currDeltaPocLt==maxPocLsb))) |
---|
| 1076 | { |
---|
| 1077 | deltaMsbCycle=deltaMsbCycle-1; |
---|
| 1078 | } |
---|
| 1079 | } |
---|
| 1080 | else |
---|
| 1081 | { |
---|
| 1082 | deltaMsbCycle=((rps->getDeltaPOC(i+1)-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 1083 | } |
---|
| 1084 | |
---|
| 1085 | if(deltaMsbCycle>=0) |
---|
| 1086 | { |
---|
| 1087 | WRITE_FLAG( 1, "delta_poc_msb_present_flag"); |
---|
| 1088 | WRITE_UVLC(deltaMsbCycle, "delta_poc_msb_cycle_lt_minus1"); |
---|
| 1089 | } |
---|
| 1090 | else |
---|
| 1091 | { |
---|
| 1092 | WRITE_FLAG( 0, "delta_poc_msb_present_flag"); |
---|
| 1093 | } |
---|
| 1094 | prevDeltaPocLt=currDeltaPocLt; |
---|
| 1095 | #endif |
---|
| 1096 | prev = rps->getDeltaPOC(i); |
---|
| 1097 | WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag"); |
---|
| 1098 | } |
---|
[2] | 1099 | } |
---|
| 1100 | } |
---|
| 1101 | } |
---|
[56] | 1102 | |
---|
| 1103 | if(pcSlice->getSPS()->getUseSAO() || pcSlice->getSPS()->getUseALF()|| pcSlice->getSPS()->getScalingListFlag() || pcSlice->getSPS()->getUseDF()) |
---|
[2] | 1104 | { |
---|
[56] | 1105 | if (pcSlice->getSPS()->getUseALF()) |
---|
[2] | 1106 | { |
---|
[56] | 1107 | #if !LCU_SYNTAX_ALF |
---|
| 1108 | if (pcSlice->getAlfEnabledFlag()) |
---|
| 1109 | { |
---|
| 1110 | assert (pcSlice->getAPS()->getAlfEnabled()); |
---|
| 1111 | } |
---|
[2] | 1112 | #endif |
---|
[56] | 1113 | WRITE_FLAG( pcSlice->getAlfEnabledFlag(), "ALF on/off flag in slice header" ); |
---|
[2] | 1114 | } |
---|
[56] | 1115 | if (pcSlice->getSPS()->getUseSAO()) |
---|
[2] | 1116 | { |
---|
[56] | 1117 | #if SAO_UNIT_INTERLEAVING |
---|
| 1118 | WRITE_FLAG( pcSlice->getSaoInterleavingFlag(), "SAO interleaving flag" ); |
---|
[2] | 1119 | #endif |
---|
[56] | 1120 | assert (pcSlice->getSaoEnabledFlag() == pcSlice->getAPS()->getSaoEnabled()); |
---|
| 1121 | WRITE_FLAG( pcSlice->getSaoEnabledFlag(), "SAO on/off flag in slice header" ); |
---|
| 1122 | #if SAO_UNIT_INTERLEAVING |
---|
| 1123 | if (pcSlice->getSaoInterleavingFlag()&&pcSlice->getSaoEnabledFlag() ) |
---|
| 1124 | { |
---|
| 1125 | WRITE_FLAG( pcSlice->getAPS()->getSaoParam()->bSaoFlag[1], "SAO on/off flag for Cb in slice header" ); |
---|
| 1126 | WRITE_FLAG( pcSlice->getAPS()->getSaoParam()->bSaoFlag[2], "SAO on/off flag for Cr in slice header" ); |
---|
| 1127 | } |
---|
| 1128 | #endif |
---|
[2] | 1129 | } |
---|
[56] | 1130 | WRITE_UVLC( pcSlice->getAPS()->getAPSID(), "aps_id"); |
---|
[2] | 1131 | } |
---|
[56] | 1132 | |
---|
[193] | 1133 | #if VSP_SLICE_HEADER && VSP_CFG |
---|
| 1134 | if( pcSlice->getSPS()->getViewId()!=0 |
---|
| 1135 | && pcSlice->getSliceType() != I_SLICE |
---|
| 1136 | && pcSlice->getSPS()->getVspPresentFlag() |
---|
| 1137 | ) |
---|
| 1138 | { |
---|
| 1139 | if( !pcSlice->getSPS()->isDepth() || pcSlice->getSPS()->getVspDepthPresentFlag() ) |
---|
| 1140 | { |
---|
| 1141 | WRITE_UVLC( pcSlice->getNumVspRefPics(), "num_vsp_ref_pics"); |
---|
| 1142 | for( UInt i = 0; i < pcSlice->getNumVspRefPics(); i++ ) |
---|
| 1143 | { |
---|
| 1144 | WRITE_UVLC( pcSlice->getVspRefPos( REF_PIC_LIST_0, i ), "vsp_ref_list0_pos"); |
---|
| 1145 | if( pcSlice->getSliceType() == B_SLICE ) |
---|
| 1146 | { |
---|
| 1147 | WRITE_UVLC( pcSlice->getVspRefPos( REF_PIC_LIST_1, i ), "vsp_ref_list1_pos"); |
---|
| 1148 | } |
---|
| 1149 | } |
---|
| 1150 | iNumOfVspRefsL0 = ( (pcSlice->getSPS()->getViewId()==0 |
---|
| 1151 | || (!pcSlice->getSPS()->getVspDepthPresentFlag() && pcSlice->getSPS()->isDepth()) |
---|
| 1152 | || !pcSlice->getVspFlag() |
---|
| 1153 | || pcSlice->getVspRefPos(REF_PIC_LIST_0, 0) == 0 ) ? 0 : 1 ); |
---|
| 1154 | iNumOfVspRefsL1 = ( (pcSlice->getSPS()->getViewId()==0 |
---|
| 1155 | || (!pcSlice->getSPS()->getVspDepthPresentFlag() && pcSlice->getSPS()->isDepth()) |
---|
| 1156 | || !pcSlice->getVspFlag() |
---|
| 1157 | || pcSlice->getVspRefPos(REF_PIC_LIST_1, 0) == 0 ) ? 0 : 1 ); |
---|
| 1158 | } |
---|
| 1159 | } |
---|
| 1160 | #endif |
---|
| 1161 | |
---|
[56] | 1162 | // we always set num_ref_idx_active_override_flag equal to one. this might be done in a more intelligent way |
---|
| 1163 | if (!pcSlice->isIntra()) |
---|
| 1164 | { |
---|
| 1165 | WRITE_FLAG( 1 , "num_ref_idx_active_override_flag"); |
---|
[193] | 1166 | #if VSP_CFG |
---|
| 1167 | WRITE_CODE( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - 1 - iNumOfVspRefsL0, 3, "num_ref_idx_l0_active_minus1" ); |
---|
| 1168 | #else |
---|
[56] | 1169 | WRITE_CODE( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - 1, 3, "num_ref_idx_l0_active_minus1" ); |
---|
[193] | 1170 | #endif |
---|
[56] | 1171 | } |
---|
[2] | 1172 | else |
---|
| 1173 | { |
---|
[56] | 1174 | pcSlice->setNumRefIdx(REF_PIC_LIST_0, 0); |
---|
[2] | 1175 | } |
---|
[56] | 1176 | if (pcSlice->isInterB()) |
---|
[2] | 1177 | { |
---|
[193] | 1178 | #if VSP_CFG |
---|
| 1179 | WRITE_CODE( pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - 1 - iNumOfVspRefsL1, 3, "num_ref_idx_l1_active_minus1" ); |
---|
| 1180 | #else |
---|
[56] | 1181 | WRITE_CODE( pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - 1, 3, "num_ref_idx_l1_active_minus1" ); |
---|
[193] | 1182 | #endif |
---|
[2] | 1183 | } |
---|
[56] | 1184 | else |
---|
[2] | 1185 | { |
---|
[56] | 1186 | pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
[2] | 1187 | } |
---|
[56] | 1188 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
| 1189 | if( pcSlice->getSPS()->getListsModificationPresentFlag() ) |
---|
| 1190 | { |
---|
[2] | 1191 | #endif |
---|
[56] | 1192 | TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); |
---|
| 1193 | #if H0137_0138_LIST_MODIFICATION |
---|
| 1194 | if( !pcSlice->isIntra() ) |
---|
[2] | 1195 | { |
---|
[56] | 1196 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0() ? 1 : 0, "ref_pic_list_modification_flag_l0" ); |
---|
| 1197 | if (pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0()) |
---|
[2] | 1198 | { |
---|
[56] | 1199 | Int NumPocTotalCurr = pcSlice->getNumPocTotalCurrMvc(); |
---|
| 1200 | if (NumPocTotalCurr > 1) |
---|
[2] | 1201 | { |
---|
[56] | 1202 | Int length = 1; |
---|
| 1203 | NumPocTotalCurr --; |
---|
| 1204 | while ( NumPocTotalCurr >>= 1) |
---|
[2] | 1205 | { |
---|
[56] | 1206 | length ++; |
---|
[2] | 1207 | } |
---|
[56] | 1208 | for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_0 ); i++) |
---|
[2] | 1209 | { |
---|
[56] | 1210 | WRITE_CODE( refPicListModification->getRefPicSetIdxL0(i), length, "list_entry_l0"); |
---|
[2] | 1211 | } |
---|
| 1212 | } |
---|
| 1213 | } |
---|
[56] | 1214 | } |
---|
| 1215 | if(pcSlice->isInterB()) |
---|
| 1216 | { |
---|
| 1217 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1() ? 1 : 0, "ref_pic_list_modification_flag_l1" ); |
---|
| 1218 | if (pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1()) |
---|
[2] | 1219 | { |
---|
[56] | 1220 | Int NumPocTotalCurr = pcSlice->getNumPocTotalCurrMvc(); |
---|
| 1221 | if ( NumPocTotalCurr > 1 ) |
---|
[2] | 1222 | { |
---|
[56] | 1223 | Int length = 1; |
---|
| 1224 | NumPocTotalCurr --; |
---|
| 1225 | while ( NumPocTotalCurr >>= 1) |
---|
[2] | 1226 | { |
---|
[56] | 1227 | length ++; |
---|
[2] | 1228 | } |
---|
[56] | 1229 | for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_1 ); i++) |
---|
[2] | 1230 | { |
---|
[56] | 1231 | WRITE_CODE( refPicListModification->getRefPicSetIdxL1(i), length, "list_entry_l1"); |
---|
[2] | 1232 | } |
---|
| 1233 | } |
---|
| 1234 | } |
---|
| 1235 | } |
---|
| 1236 | #else |
---|
[56] | 1237 | if(!pcSlice->isIntra()) |
---|
[2] | 1238 | { |
---|
[56] | 1239 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0() ? 1 : 0, "ref_pic_list_modification_flag" ); |
---|
| 1240 | for(Int i = 0; i < refPicListModification->getNumberOfRefPicListModificationsL0(); i++) |
---|
[2] | 1241 | { |
---|
[56] | 1242 | WRITE_UVLC( refPicListModification->getListIdcL0(i), "ref_pic_list_modification_idc"); |
---|
| 1243 | WRITE_UVLC( refPicListModification->getRefPicSetIdxL0(i), "ref_pic_set_idx"); |
---|
[2] | 1244 | } |
---|
[56] | 1245 | if(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0()) |
---|
| 1246 | WRITE_UVLC( 3, "ref_pic_list_modification_idc"); |
---|
| 1247 | } |
---|
| 1248 | if(pcSlice->isInterB()) |
---|
| 1249 | { |
---|
| 1250 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1() ? 1 : 0, "ref_pic_list_modification_flag" ); |
---|
| 1251 | for(Int i = 0; i < refPicListModification->getNumberOfRefPicListModificationsL1(); i++) |
---|
[2] | 1252 | { |
---|
[56] | 1253 | WRITE_UVLC( refPicListModification->getListIdcL1(i), "ref_pic_list_modification_idc"); |
---|
| 1254 | WRITE_UVLC( refPicListModification->getRefPicSetIdxL1(i), "ref_pic_set_idx"); |
---|
[2] | 1255 | } |
---|
[56] | 1256 | if(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1()) |
---|
| 1257 | WRITE_UVLC( 3, "ref_pic_list_modification_idc"); |
---|
[2] | 1258 | } |
---|
[56] | 1259 | #endif |
---|
| 1260 | } |
---|
| 1261 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
| 1262 | } |
---|
| 1263 | #endif |
---|
| 1264 | // ref_pic_list_combination( ) |
---|
| 1265 | // maybe move to own function? |
---|
| 1266 | if (pcSlice->isInterB()) |
---|
| 1267 | { |
---|
| 1268 | WRITE_FLAG(pcSlice->getRefPicListCombinationFlag() ? 1 : 0, "ref_pic_list_combination_flag" ); |
---|
| 1269 | if(pcSlice->getRefPicListCombinationFlag()) |
---|
| 1270 | { |
---|
[193] | 1271 | #if VSP_CFG |
---|
| 1272 | WRITE_UVLC( pcSlice->getNumRefIdx(REF_PIC_LIST_C) - 1 - iNumOfVspRefsL0, "num_ref_idx lc_active_minus1"); |
---|
| 1273 | #else |
---|
[56] | 1274 | WRITE_UVLC( pcSlice->getNumRefIdx(REF_PIC_LIST_C) - 1, "num_ref_idx lc_active_minus1"); |
---|
[193] | 1275 | #endif |
---|
[56] | 1276 | |
---|
| 1277 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
| 1278 | if( pcSlice->getSPS()->getListsModificationPresentFlag() ) |
---|
[2] | 1279 | { |
---|
[56] | 1280 | #endif |
---|
| 1281 | WRITE_FLAG( pcSlice->getRefPicListModificationFlagLC() ? 1 : 0, "ref_pic_list_modification_flag_lc" ); |
---|
| 1282 | if(pcSlice->getRefPicListModificationFlagLC()) |
---|
[2] | 1283 | { |
---|
[56] | 1284 | for (UInt i=0;i<pcSlice->getNumRefIdx(REF_PIC_LIST_C);i++) |
---|
| 1285 | { |
---|
| 1286 | WRITE_FLAG( pcSlice->getListIdFromIdxOfLC(i), "pic_from_list_0_flag" ); |
---|
| 1287 | #if H0137_0138_LIST_MODIFICATION |
---|
| 1288 | if (((pcSlice->getListIdFromIdxOfLC(i)==REF_PIC_LIST_0) && pcSlice->getNumRefIdx( REF_PIC_LIST_0 )>1 ) || ((pcSlice->getListIdFromIdxOfLC(i)==REF_PIC_LIST_1) && pcSlice->getNumRefIdx( REF_PIC_LIST_1 )>1 ) ) |
---|
| 1289 | { |
---|
| 1290 | WRITE_UVLC( pcSlice->getRefIdxFromIdxOfLC(i), "ref_idx_list_curr" ); |
---|
| 1291 | } |
---|
| 1292 | #else |
---|
| 1293 | WRITE_UVLC( pcSlice->getRefIdxFromIdxOfLC(i), "ref_idx_list_curr" ); |
---|
| 1294 | #endif |
---|
| 1295 | } |
---|
[2] | 1296 | } |
---|
[56] | 1297 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
[2] | 1298 | } |
---|
| 1299 | #endif |
---|
| 1300 | } |
---|
| 1301 | } |
---|
[56] | 1302 | |
---|
| 1303 | #if H0111_MVD_L1_ZERO |
---|
| 1304 | if (pcSlice->isInterB()) |
---|
[2] | 1305 | { |
---|
[56] | 1306 | WRITE_FLAG( pcSlice->getMvdL1ZeroFlag() ? 1 : 0, "mvd_l1_zero_flag"); |
---|
[2] | 1307 | } |
---|
| 1308 | #endif |
---|
| 1309 | |
---|
[56] | 1310 | if(pcSlice->getPPS()->getEntropyCodingMode() && !pcSlice->isIntra()) |
---|
[2] | 1311 | { |
---|
[56] | 1312 | #if CABAC_INIT_FLAG |
---|
| 1313 | if (!pcSlice->isIntra() && pcSlice->getPPS()->getCabacInitPresentFlag()) |
---|
[2] | 1314 | { |
---|
[56] | 1315 | SliceType sliceType = pcSlice->getSliceType(); |
---|
| 1316 | Int encCABACTableIdx = pcSlice->getPPS()->getEncCABACTableIdx(); |
---|
| 1317 | Bool encCabacInitFlag = (sliceType!=encCABACTableIdx && encCABACTableIdx!=0) ? true : false; |
---|
| 1318 | pcSlice->setCabacInitFlag( encCabacInitFlag ); |
---|
| 1319 | WRITE_FLAG( encCabacInitFlag?1:0, "cabac_init_flag" ); |
---|
[2] | 1320 | } |
---|
| 1321 | #else |
---|
[56] | 1322 | WRITE_UVLC(pcSlice->getCABACinitIDC(), "cabac_init_idc"); |
---|
[2] | 1323 | #endif |
---|
| 1324 | } |
---|
| 1325 | |
---|
[56] | 1326 | // if( !lightweight_slice_flag ) { |
---|
| 1327 | if (!bEntropySlice) |
---|
[2] | 1328 | { |
---|
[56] | 1329 | Int iCode = pcSlice->getSliceQp() - ( pcSlice->getPPS()->getPicInitQPMinus26() + 26 ); |
---|
| 1330 | WRITE_SVLC( iCode, "slice_qp_delta" ); |
---|
| 1331 | #if DBL_CONTROL |
---|
| 1332 | if (pcSlice->getPPS()->getDeblockingFilterControlPresent()) |
---|
[2] | 1333 | { |
---|
[56] | 1334 | if ( pcSlice->getSPS()->getUseDF() ) |
---|
[2] | 1335 | { |
---|
[56] | 1336 | WRITE_FLAG(pcSlice->getInheritDblParamFromAPS(), "inherit_dbl_param_from_APS_flag"); |
---|
[2] | 1337 | } |
---|
[56] | 1338 | #else |
---|
| 1339 | WRITE_FLAG(pcSlice->getInheritDblParamFromAPS(), "inherit_dbl_param_from_APS_flag"); |
---|
| 1340 | #endif |
---|
| 1341 | if (!pcSlice->getInheritDblParamFromAPS()) |
---|
[2] | 1342 | { |
---|
[56] | 1343 | WRITE_FLAG(pcSlice->getLoopFilterDisable(), "loop_filter_disable"); // should be an IDC |
---|
| 1344 | if(!pcSlice->getLoopFilterDisable()) |
---|
| 1345 | { |
---|
| 1346 | WRITE_SVLC (pcSlice->getLoopFilterBetaOffset(), "beta_offset_div2"); |
---|
| 1347 | WRITE_SVLC (pcSlice->getLoopFilterTcOffset(), "tc_offset_div2"); |
---|
| 1348 | } |
---|
[2] | 1349 | } |
---|
[56] | 1350 | #if DBL_CONTROL |
---|
| 1351 | } |
---|
| 1352 | #endif |
---|
| 1353 | if ( pcSlice->getSliceType() == B_SLICE ) |
---|
| 1354 | { |
---|
| 1355 | WRITE_FLAG( pcSlice->getColDir(), "collocated_from_l0_flag" ); |
---|
| 1356 | } |
---|
[2] | 1357 | |
---|
[56] | 1358 | #if COLLOCATED_REF_IDX |
---|
| 1359 | if ( pcSlice->getSliceType() != I_SLICE && |
---|
| 1360 | ((pcSlice->getColDir()==0 && pcSlice->getNumRefIdx(REF_PIC_LIST_0)>1)|| |
---|
| 1361 | (pcSlice->getColDir()==1 && pcSlice->getNumRefIdx(REF_PIC_LIST_1)>1))) |
---|
| 1362 | { |
---|
| 1363 | WRITE_UVLC( pcSlice->getColRefIdx(), "collocated_ref_idx" ); |
---|
[2] | 1364 | } |
---|
[56] | 1365 | #endif |
---|
| 1366 | |
---|
| 1367 | if ( (pcSlice->getPPS()->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pcSlice->getPPS()->getWPBiPredIdc()==1 && pcSlice->getSliceType()==B_SLICE) ) |
---|
[2] | 1368 | { |
---|
[56] | 1369 | xCodePredWeightTable( pcSlice ); |
---|
[2] | 1370 | } |
---|
| 1371 | } |
---|
| 1372 | |
---|
[56] | 1373 | // !!!! sytnax elements not in the WD !!!! |
---|
| 1374 | if (!bEntropySlice) |
---|
[2] | 1375 | { |
---|
[56] | 1376 | if( pcSlice->getSPS()->hasCamParInSliceHeader() ) |
---|
| 1377 | { |
---|
| 1378 | for( UInt uiId = 0; uiId < pcSlice->getSPS()->getViewId(); uiId++ ) |
---|
| 1379 | { |
---|
| 1380 | WRITE_SVLC( pcSlice->getCodedScale ()[ uiId ], "coded_scale" ); |
---|
| 1381 | WRITE_SVLC( pcSlice->getCodedOffset ()[ uiId ], "coded_offset" ); |
---|
| 1382 | WRITE_SVLC( pcSlice->getInvCodedScale ()[ uiId ] + pcSlice->getCodedScale ()[ uiId ], "inverse_coded_scale_plus_coded_scale" ); |
---|
| 1383 | WRITE_SVLC( pcSlice->getInvCodedOffset()[ uiId ] + pcSlice->getCodedOffset()[ uiId ], "inverse_coded_offset_plus_coded_offset" ); |
---|
| 1384 | } |
---|
| 1385 | } |
---|
[2] | 1386 | } |
---|
[56] | 1387 | |
---|
| 1388 | #if ( HHI_MPI || HHI_INTER_VIEW_MOTION_PRED ) |
---|
| 1389 | #if ( HHI_MPI && HHI_INTER_VIEW_MOTION_PRED ) |
---|
| 1390 | const int iExtraMergeCandidates = ( pcSlice->getSPS()->getUseMVI() || pcSlice->getSPS()->getMultiviewMvPredMode() ) ? 1 : 0; |
---|
| 1391 | #elif HHI_MPI |
---|
| 1392 | const int iExtraMergeCandidates = pcSlice->getSPS()->getUseMVI() ? 1 : 0; |
---|
| 1393 | #else |
---|
| 1394 | const int iExtraMergeCandidates = pcSlice->getSPS()->getMultiviewMvPredMode() ? 1 : 0; |
---|
| 1395 | #endif |
---|
| 1396 | assert(pcSlice->getMaxNumMergeCand()<=(MRG_MAX_NUM_CANDS_SIGNALED+iExtraMergeCandidates)); |
---|
| 1397 | assert(MRG_MAX_NUM_CANDS_SIGNALED<=MRG_MAX_NUM_CANDS); |
---|
| 1398 | WRITE_UVLC(MRG_MAX_NUM_CANDS + iExtraMergeCandidates - pcSlice->getMaxNumMergeCand(), "maxNumMergeCand"); |
---|
[2] | 1399 | #else |
---|
[56] | 1400 | assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS_SIGNALED); |
---|
| 1401 | assert(MRG_MAX_NUM_CANDS_SIGNALED<=MRG_MAX_NUM_CANDS); |
---|
| 1402 | WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSlice->getMaxNumMergeCand(), "maxNumMergeCand"); |
---|
[2] | 1403 | #endif |
---|
[166] | 1404 | |
---|
[193] | 1405 | #if !VSP_CFG |
---|
[166] | 1406 | #if VSP_SLICE_HEADER |
---|
| 1407 | if( pcSlice->getSPS()->getViewId()!=0 |
---|
[193] | 1408 | && pcSlice->getSPS()->getVspPresentFlag() |
---|
[166] | 1409 | ) |
---|
| 1410 | { |
---|
| 1411 | WRITE_FLAG( pcSlice->getVspFlag()?1:0, "vsp_flag" ); |
---|
| 1412 | // printf("[VSP: %d] ", pcSlice->getVspFlag()?1:0); |
---|
[193] | 1413 | if( pcSlice->getVspFlag() ) |
---|
| 1414 | { |
---|
| 1415 | WRITE_FLAG( pcSlice->getVspDepthDisableFlag()?1:0 , "vsp_depth_disable_flag" ); |
---|
| 1416 | } |
---|
[166] | 1417 | } |
---|
| 1418 | #endif |
---|
[193] | 1419 | #endif |
---|
[2] | 1420 | } |
---|
| 1421 | |
---|
| 1422 | |
---|
[56] | 1423 | Void TEncCavlc::codeTileMarkerFlag(TComSlice* pcSlice) |
---|
[2] | 1424 | { |
---|
[56] | 1425 | Bool bEntropySlice = (!pcSlice->isNextSlice()); |
---|
| 1426 | if (!bEntropySlice) |
---|
| 1427 | { |
---|
| 1428 | xWriteFlag (pcSlice->getTileMarkerFlag() ? 1 : 0 ); |
---|
| 1429 | } |
---|
[2] | 1430 | } |
---|
| 1431 | |
---|
[56] | 1432 | /** |
---|
| 1433 | - write wavefront substreams sizes for the slice header. |
---|
| 1434 | . |
---|
| 1435 | \param pcSlice Where we find the substream size information. |
---|
| 1436 | */ |
---|
| 1437 | #if TILES_WPP_ENTRY_POINT_SIGNALLING |
---|
| 1438 | Void TEncCavlc::codeTilesWPPEntryPoint( TComSlice* pSlice ) |
---|
[2] | 1439 | { |
---|
[56] | 1440 | Int tilesOrEntropyCodingSyncIdc = pSlice->getSPS()->getTilesOrEntropyCodingSyncIdc(); |
---|
[2] | 1441 | |
---|
[56] | 1442 | if ( tilesOrEntropyCodingSyncIdc == 0 ) |
---|
[2] | 1443 | { |
---|
[56] | 1444 | return; |
---|
[2] | 1445 | } |
---|
| 1446 | |
---|
[56] | 1447 | UInt numEntryPointOffsets = 0, offsetLenMinus1 = 0, maxOffset = 0; |
---|
| 1448 | UInt *entryPointOffset = NULL; |
---|
| 1449 | if (tilesOrEntropyCodingSyncIdc == 1) // tiles |
---|
[2] | 1450 | { |
---|
[56] | 1451 | numEntryPointOffsets = pSlice->getTileLocationCount(); |
---|
| 1452 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
| 1453 | for (Int idx=0; idx<pSlice->getTileLocationCount(); idx++) |
---|
[2] | 1454 | { |
---|
[56] | 1455 | if ( idx == 0 ) |
---|
[2] | 1456 | { |
---|
[56] | 1457 | entryPointOffset [ idx ] = pSlice->getTileLocation( 0 ); |
---|
[2] | 1458 | } |
---|
[56] | 1459 | else |
---|
[2] | 1460 | { |
---|
[56] | 1461 | entryPointOffset [ idx ] = pSlice->getTileLocation( idx ) - pSlice->getTileLocation( idx-1 ); |
---|
[2] | 1462 | } |
---|
| 1463 | |
---|
[56] | 1464 | if ( entryPointOffset[ idx ] > maxOffset ) |
---|
| 1465 | { |
---|
| 1466 | maxOffset = entryPointOffset[ idx ]; |
---|
| 1467 | } |
---|
[2] | 1468 | } |
---|
| 1469 | } |
---|
[56] | 1470 | else if (tilesOrEntropyCodingSyncIdc == 2) // wavefront |
---|
[2] | 1471 | { |
---|
[56] | 1472 | Int numZeroSubstreamsAtEndOfSlice = 0; |
---|
| 1473 | UInt* pSubstreamSizes = pSlice->getSubstreamSizes(); |
---|
| 1474 | // Find number of zero substreams at the end of slice |
---|
| 1475 | for (Int idx=pSlice->getPPS()->getNumSubstreams()-2; idx>=0; idx--) |
---|
[2] | 1476 | { |
---|
[56] | 1477 | if ( pSubstreamSizes[ idx ] == 0 ) |
---|
[2] | 1478 | { |
---|
[56] | 1479 | numZeroSubstreamsAtEndOfSlice++; |
---|
[2] | 1480 | } |
---|
[56] | 1481 | else |
---|
[2] | 1482 | { |
---|
[56] | 1483 | break; |
---|
[2] | 1484 | } |
---|
| 1485 | } |
---|
[56] | 1486 | numEntryPointOffsets = pSlice->getPPS()->getNumSubstreams() - 1 - numZeroSubstreamsAtEndOfSlice; |
---|
| 1487 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
| 1488 | for (Int idx=0; idx<numEntryPointOffsets; idx++) |
---|
[2] | 1489 | { |
---|
[56] | 1490 | entryPointOffset[ idx ] = ( pSubstreamSizes[ idx ] >> 3 ) ; |
---|
| 1491 | if ( entryPointOffset[ idx ] > maxOffset ) |
---|
[2] | 1492 | { |
---|
[56] | 1493 | maxOffset = entryPointOffset[ idx ]; |
---|
[2] | 1494 | } |
---|
| 1495 | } |
---|
[56] | 1496 | } |
---|
[2] | 1497 | |
---|
[56] | 1498 | maxOffset += ((m_pcBitIf->getNumberOfWrittenBits() + 16) >> 3) + 8 + 2; // allowing for NALU header, slice header, bytes added for "offset_len_minus1" and "num_entry_point_offsets" |
---|
[2] | 1499 | |
---|
[56] | 1500 | // Determine number of bits "offsetLenMinus1+1" required for entry point information |
---|
| 1501 | offsetLenMinus1 = 0; |
---|
| 1502 | while (1) |
---|
| 1503 | { |
---|
| 1504 | if (maxOffset >= (1 << offsetLenMinus1) ) |
---|
| 1505 | { |
---|
| 1506 | offsetLenMinus1++; |
---|
| 1507 | if ( offsetLenMinus1 > 32 ) |
---|
[2] | 1508 | { |
---|
[56] | 1509 | FATAL_ERROR_0("exceeded 32-bits", -1); |
---|
[2] | 1510 | } |
---|
| 1511 | } |
---|
[56] | 1512 | else |
---|
[2] | 1513 | { |
---|
[56] | 1514 | break; |
---|
[2] | 1515 | } |
---|
| 1516 | } |
---|
| 1517 | |
---|
[56] | 1518 | WRITE_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); |
---|
| 1519 | if (numEntryPointOffsets>0) |
---|
[2] | 1520 | { |
---|
[56] | 1521 | WRITE_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
[2] | 1522 | } |
---|
[56] | 1523 | |
---|
| 1524 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
[2] | 1525 | { |
---|
[56] | 1526 | if ( idx == 0 ) |
---|
| 1527 | { |
---|
| 1528 | // Adding sizes of NALU header and slice header information to entryPointOffset[ 0 ] |
---|
| 1529 | Int bitDistFromNALUHdrStart = m_pcBitIf->getNumberOfWrittenBits() + 16; |
---|
| 1530 | entryPointOffset[ idx ] += ( bitDistFromNALUHdrStart + numEntryPointOffsets*(offsetLenMinus1+1) ) >> 3; |
---|
| 1531 | } |
---|
| 1532 | WRITE_CODE(entryPointOffset[ idx ], offsetLenMinus1+1, "entry_point_offset"); |
---|
[2] | 1533 | } |
---|
| 1534 | |
---|
[56] | 1535 | delete [] entryPointOffset; |
---|
[2] | 1536 | } |
---|
[56] | 1537 | #else |
---|
| 1538 | Void TEncCavlc::codeSliceHeaderSubstreamTable( TComSlice* pcSlice ) |
---|
| 1539 | { |
---|
| 1540 | UInt uiNumSubstreams = pcSlice->getPPS()->getNumSubstreams(); |
---|
| 1541 | UInt*puiSubstreamSizes = pcSlice->getSubstreamSizes(); |
---|
[2] | 1542 | |
---|
[56] | 1543 | // Write header information for all substreams except the last. |
---|
| 1544 | for (UInt ui = 0; ui+1 < uiNumSubstreams; ui++) |
---|
[2] | 1545 | { |
---|
[56] | 1546 | UInt uiNumbits = puiSubstreamSizes[ui]; |
---|
[2] | 1547 | |
---|
[56] | 1548 | //the 2 first bits are used to give the size of the header |
---|
| 1549 | if ( uiNumbits < (1<<8) ) |
---|
[2] | 1550 | { |
---|
[56] | 1551 | xWriteCode(0, 2 ); |
---|
| 1552 | xWriteCode(uiNumbits, 8 ); |
---|
[2] | 1553 | } |
---|
[56] | 1554 | else if ( uiNumbits < (1<<16) ) |
---|
| 1555 | { |
---|
| 1556 | xWriteCode(1, 2 ); |
---|
| 1557 | xWriteCode(uiNumbits, 16 ); |
---|
| 1558 | } |
---|
| 1559 | else if ( uiNumbits < (1<<24) ) |
---|
| 1560 | { |
---|
| 1561 | xWriteCode(2, 2 ); |
---|
| 1562 | xWriteCode(uiNumbits, 24 ); |
---|
| 1563 | } |
---|
| 1564 | else if ( uiNumbits < (1<<31) ) |
---|
| 1565 | { |
---|
| 1566 | xWriteCode(3, 2 ); |
---|
| 1567 | xWriteCode(uiNumbits, 32 ); |
---|
| 1568 | } |
---|
| 1569 | else |
---|
| 1570 | { |
---|
| 1571 | printf("Error in codeSliceHeaderTable\n"); |
---|
| 1572 | exit(-1); |
---|
| 1573 | } |
---|
[2] | 1574 | } |
---|
| 1575 | } |
---|
[56] | 1576 | #endif |
---|
[2] | 1577 | |
---|
[56] | 1578 | Void TEncCavlc::codeTerminatingBit ( UInt uilsLast ) |
---|
[2] | 1579 | { |
---|
[56] | 1580 | } |
---|
[2] | 1581 | |
---|
[56] | 1582 | Void TEncCavlc::codeSliceFinish () |
---|
| 1583 | { |
---|
| 1584 | } |
---|
[2] | 1585 | |
---|
[56] | 1586 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
| 1587 | Void TEncCavlc::codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Int iNum ) |
---|
[2] | 1588 | #else |
---|
[56] | 1589 | Void TEncCavlc::codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
[2] | 1590 | #endif |
---|
[56] | 1591 | { |
---|
| 1592 | assert(0); |
---|
| 1593 | } |
---|
[2] | 1594 | |
---|
[56] | 1595 | Void TEncCavlc::codePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1596 | { |
---|
| 1597 | assert(0); |
---|
| 1598 | } |
---|
[2] | 1599 | |
---|
[56] | 1600 | Void TEncCavlc::codePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1601 | { |
---|
| 1602 | assert(0); |
---|
| 1603 | } |
---|
[2] | 1604 | |
---|
[56] | 1605 | Void TEncCavlc::codeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1606 | { |
---|
| 1607 | assert(0); |
---|
| 1608 | } |
---|
[2] | 1609 | |
---|
[56] | 1610 | Void TEncCavlc::codeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1611 | { |
---|
| 1612 | assert(0); |
---|
| 1613 | } |
---|
[2] | 1614 | |
---|
[56] | 1615 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 1616 | Void |
---|
| 1617 | TEncCavlc::codeResPredFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1618 | { |
---|
| 1619 | assert(0); |
---|
| 1620 | } |
---|
[2] | 1621 | #endif |
---|
| 1622 | |
---|
[56] | 1623 | Void TEncCavlc::codeAlfCtrlFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1624 | { |
---|
| 1625 | if (!m_bAlfCtrl) |
---|
| 1626 | { |
---|
| 1627 | return; |
---|
[2] | 1628 | } |
---|
[56] | 1629 | |
---|
| 1630 | if( pcCU->getDepth(uiAbsPartIdx) > m_uiMaxAlfCtrlDepth && !pcCU->isFirstAbsZorderIdxInDepth(uiAbsPartIdx, m_uiMaxAlfCtrlDepth)) |
---|
| 1631 | { |
---|
| 1632 | return; |
---|
| 1633 | } |
---|
| 1634 | |
---|
| 1635 | // get context function is here |
---|
| 1636 | UInt uiSymbol = pcCU->getAlfCtrlFlag( uiAbsPartIdx ) ? 1 : 0; |
---|
| 1637 | |
---|
| 1638 | xWriteFlag( uiSymbol ); |
---|
| 1639 | } |
---|
[2] | 1640 | |
---|
[56] | 1641 | Void TEncCavlc::codeApsExtensionFlag () |
---|
| 1642 | { |
---|
| 1643 | WRITE_FLAG(0, "aps_extension_flag"); |
---|
[2] | 1644 | } |
---|
| 1645 | |
---|
[56] | 1646 | Void TEncCavlc::codeAlfCtrlDepth() |
---|
| 1647 | { |
---|
| 1648 | if (!m_bAlfCtrl) |
---|
[2] | 1649 | { |
---|
[56] | 1650 | return; |
---|
[2] | 1651 | } |
---|
[56] | 1652 | |
---|
| 1653 | UInt uiDepth = m_uiMaxAlfCtrlDepth; |
---|
| 1654 | |
---|
| 1655 | xWriteUvlc(uiDepth); |
---|
| 1656 | } |
---|
[2] | 1657 | |
---|
[56] | 1658 | Void TEncCavlc::codeInterModeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiEncMode ) |
---|
| 1659 | { |
---|
| 1660 | assert(0); |
---|
| 1661 | } |
---|
[2] | 1662 | |
---|
[56] | 1663 | Void TEncCavlc::codeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1664 | { |
---|
| 1665 | assert(0); |
---|
| 1666 | } |
---|
[2] | 1667 | |
---|
[213] | 1668 | #if LGE_ILLUCOMP_B0045 |
---|
| 1669 | Void TEncCavlc::codeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1670 | { |
---|
| 1671 | assert(0); |
---|
| 1672 | } |
---|
| 1673 | #endif |
---|
| 1674 | |
---|
[166] | 1675 | #if FORCE_REF_VSP==1 |
---|
| 1676 | Void TEncCavlc::codeVspFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1677 | { |
---|
| 1678 | assert(0); |
---|
| 1679 | } |
---|
| 1680 | #endif |
---|
| 1681 | |
---|
[56] | 1682 | Void TEncCavlc::codeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1683 | { |
---|
| 1684 | assert(0); |
---|
| 1685 | } |
---|
[2] | 1686 | |
---|
[56] | 1687 | Void TEncCavlc::codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) |
---|
| 1688 | { |
---|
| 1689 | assert(0); |
---|
| 1690 | } |
---|
[2] | 1691 | |
---|
[56] | 1692 | Void TEncCavlc::codeQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) |
---|
| 1693 | { |
---|
| 1694 | assert(0); |
---|
| 1695 | } |
---|
[2] | 1696 | |
---|
[56] | 1697 | Void TEncCavlc::codeQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1698 | { |
---|
| 1699 | assert(0); |
---|
| 1700 | } |
---|
[2] | 1701 | |
---|
[56] | 1702 | #if BURST_IPCM |
---|
| 1703 | /** Code I_PCM information. |
---|
| 1704 | * \param pcCU pointer to CU |
---|
| 1705 | * \param uiAbsPartIdx CU index |
---|
| 1706 | * \param numIPCM the number of succesive IPCM blocks with the same size |
---|
| 1707 | * \param firstIPCMFlag |
---|
| 1708 | * \returns Void |
---|
| 1709 | */ |
---|
| 1710 | Void TEncCavlc::codeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, Int numIPCM, Bool firstIPCMFlag) |
---|
| 1711 | { |
---|
| 1712 | assert(0); |
---|
| 1713 | } |
---|
[2] | 1714 | #else |
---|
[56] | 1715 | /** Code I_PCM information. |
---|
| 1716 | * \param pcCU pointer to CU |
---|
| 1717 | * \param uiAbsPartIdx CU index |
---|
| 1718 | * \returns Void |
---|
| 1719 | * |
---|
| 1720 | * If I_PCM flag indicates that the CU is I_PCM, code its PCM alignment bits and codes. |
---|
| 1721 | */ |
---|
| 1722 | Void TEncCavlc::codeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx) |
---|
| 1723 | { |
---|
| 1724 | UInt uiIPCM = (pcCU->getIPCMFlag(uiAbsPartIdx) == true)? 1 : 0; |
---|
[2] | 1725 | |
---|
[56] | 1726 | xWriteFlag(uiIPCM); |
---|
[2] | 1727 | |
---|
[56] | 1728 | if (uiIPCM) |
---|
[2] | 1729 | { |
---|
[56] | 1730 | xWritePCMAlignZero(); |
---|
[2] | 1731 | |
---|
[56] | 1732 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
| 1733 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
| 1734 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
[2] | 1735 | |
---|
[56] | 1736 | Pel* piPCMSample; |
---|
| 1737 | UInt uiWidth; |
---|
| 1738 | UInt uiHeight; |
---|
| 1739 | UInt uiSampleBits; |
---|
| 1740 | UInt uiX, uiY; |
---|
[2] | 1741 | |
---|
[56] | 1742 | piPCMSample = pcCU->getPCMSampleY() + uiLumaOffset; |
---|
| 1743 | uiWidth = pcCU->getWidth(uiAbsPartIdx); |
---|
| 1744 | uiHeight = pcCU->getHeight(uiAbsPartIdx); |
---|
| 1745 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
| 1746 | |
---|
| 1747 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
[2] | 1748 | { |
---|
[56] | 1749 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
[2] | 1750 | { |
---|
[56] | 1751 | UInt uiSample = piPCMSample[uiX]; |
---|
| 1752 | |
---|
| 1753 | xWriteCode(uiSample, uiSampleBits); |
---|
[2] | 1754 | } |
---|
[56] | 1755 | piPCMSample += uiWidth; |
---|
[2] | 1756 | } |
---|
| 1757 | |
---|
[56] | 1758 | piPCMSample = pcCU->getPCMSampleCb() + uiChromaOffset; |
---|
| 1759 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
| 1760 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
| 1761 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
| 1762 | |
---|
| 1763 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
[2] | 1764 | { |
---|
[56] | 1765 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
[2] | 1766 | { |
---|
[56] | 1767 | UInt uiSample = piPCMSample[uiX]; |
---|
| 1768 | |
---|
| 1769 | xWriteCode(uiSample, uiSampleBits); |
---|
[2] | 1770 | } |
---|
[56] | 1771 | piPCMSample += uiWidth; |
---|
[2] | 1772 | } |
---|
| 1773 | |
---|
[56] | 1774 | piPCMSample = pcCU->getPCMSampleCr() + uiChromaOffset; |
---|
| 1775 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
| 1776 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
| 1777 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
| 1778 | |
---|
| 1779 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
[2] | 1780 | { |
---|
[56] | 1781 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
| 1782 | { |
---|
| 1783 | UInt uiSample = piPCMSample[uiX]; |
---|
| 1784 | |
---|
| 1785 | xWriteCode(uiSample, uiSampleBits); |
---|
| 1786 | } |
---|
| 1787 | piPCMSample += uiWidth; |
---|
[2] | 1788 | } |
---|
[56] | 1789 | } |
---|
| 1790 | } |
---|
[2] | 1791 | #endif |
---|
| 1792 | |
---|
[56] | 1793 | Void TEncCavlc::codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1794 | { |
---|
| 1795 | assert(0); |
---|
| 1796 | } |
---|
[2] | 1797 | |
---|
[56] | 1798 | Void TEncCavlc::codeIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1799 | { |
---|
| 1800 | assert(0); |
---|
[2] | 1801 | } |
---|
| 1802 | |
---|
[56] | 1803 | Void TEncCavlc::codeInterDir( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
[2] | 1804 | { |
---|
[56] | 1805 | assert(0); |
---|
| 1806 | } |
---|
[2] | 1807 | |
---|
[56] | 1808 | Void TEncCavlc::codeRefFrmIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
| 1809 | { |
---|
| 1810 | assert(0); |
---|
[2] | 1811 | } |
---|
| 1812 | |
---|
[56] | 1813 | Void TEncCavlc::codeMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
[2] | 1814 | { |
---|
[56] | 1815 | assert(0); |
---|
[2] | 1816 | } |
---|
| 1817 | |
---|
[56] | 1818 | Void TEncCavlc::codeDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1819 | { |
---|
| 1820 | Int iDQp = pcCU->getQP( uiAbsPartIdx ) - pcCU->getRefQP( uiAbsPartIdx ); |
---|
| 1821 | |
---|
| 1822 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1823 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
| 1824 | iDQp = (iDQp + 78 + qpBdOffsetY + (qpBdOffsetY/2)) % (52 + qpBdOffsetY) - 26 - (qpBdOffsetY/2); |
---|
| 1825 | #endif |
---|
| 1826 | |
---|
| 1827 | xWriteSvlc( iDQp ); |
---|
| 1828 | |
---|
| 1829 | return; |
---|
| 1830 | } |
---|
| 1831 | |
---|
| 1832 | Void TEncCavlc::codeCoeffNxN ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) |
---|
| 1833 | { |
---|
| 1834 | assert(0); |
---|
| 1835 | } |
---|
| 1836 | |
---|
| 1837 | Void TEncCavlc::codeAlfFlag( UInt uiCode ) |
---|
| 1838 | { |
---|
| 1839 | xWriteFlag( uiCode ); |
---|
| 1840 | } |
---|
| 1841 | |
---|
[2] | 1842 | Void TEncCavlc::codeAlfCtrlFlag( UInt uiSymbol ) |
---|
| 1843 | { |
---|
| 1844 | xWriteFlag( uiSymbol ); |
---|
| 1845 | } |
---|
| 1846 | |
---|
| 1847 | Void TEncCavlc::codeAlfUvlc( UInt uiCode ) |
---|
| 1848 | { |
---|
| 1849 | xWriteUvlc( uiCode ); |
---|
| 1850 | } |
---|
| 1851 | |
---|
| 1852 | Void TEncCavlc::codeAlfSvlc( Int iCode ) |
---|
| 1853 | { |
---|
| 1854 | xWriteSvlc( iCode ); |
---|
| 1855 | } |
---|
[56] | 1856 | #if LCU_SYNTAX_ALF |
---|
| 1857 | /** Code the fixed length code (smaller than one max value) in OSALF |
---|
| 1858 | * \param idx: coded value |
---|
| 1859 | * \param maxValue: max value |
---|
| 1860 | */ |
---|
| 1861 | Void TEncCavlc::codeAlfFixedLengthIdx( UInt idx, UInt maxValue) |
---|
[2] | 1862 | { |
---|
[56] | 1863 | UInt length = 0; |
---|
| 1864 | assert(idx<=maxValue); |
---|
[2] | 1865 | |
---|
[56] | 1866 | UInt temp = maxValue; |
---|
| 1867 | for(UInt i=0; i<32; i++) |
---|
| 1868 | { |
---|
| 1869 | if(temp&0x1) |
---|
| 1870 | { |
---|
| 1871 | length = i+1; |
---|
| 1872 | } |
---|
| 1873 | temp = (temp >> 1); |
---|
| 1874 | } |
---|
| 1875 | |
---|
| 1876 | if(length) |
---|
| 1877 | { |
---|
| 1878 | xWriteCode( idx, length ); |
---|
| 1879 | } |
---|
| 1880 | } |
---|
| 1881 | #endif |
---|
| 1882 | |
---|
| 1883 | Void TEncCavlc::codeSaoFlag( UInt uiCode ) |
---|
| 1884 | { |
---|
[2] | 1885 | xWriteFlag( uiCode ); |
---|
| 1886 | } |
---|
| 1887 | |
---|
[56] | 1888 | Void TEncCavlc::codeSaoUvlc( UInt uiCode ) |
---|
[2] | 1889 | { |
---|
| 1890 | xWriteUvlc( uiCode ); |
---|
| 1891 | } |
---|
| 1892 | |
---|
[56] | 1893 | Void TEncCavlc::codeSaoSvlc( Int iCode ) |
---|
[2] | 1894 | { |
---|
| 1895 | xWriteSvlc( iCode ); |
---|
| 1896 | } |
---|
[56] | 1897 | #if SAO_UNIT_INTERLEAVING |
---|
| 1898 | /** Code SAO run. |
---|
| 1899 | * \param uiCode |
---|
| 1900 | * \param maxValue |
---|
| 1901 | */ |
---|
| 1902 | Void TEncCavlc::codeSaoRun( UInt uiCode, UInt maxValue) |
---|
| 1903 | { |
---|
| 1904 | UInt uiLength = 0; |
---|
| 1905 | if (!maxValue) |
---|
| 1906 | { |
---|
| 1907 | return; |
---|
| 1908 | } |
---|
| 1909 | assert(uiCode<=maxValue); |
---|
[2] | 1910 | |
---|
[56] | 1911 | for(UInt i=0; i<32; i++) |
---|
| 1912 | { |
---|
| 1913 | if(maxValue&0x1) |
---|
| 1914 | { |
---|
| 1915 | uiLength = i+1; |
---|
| 1916 | } |
---|
| 1917 | maxValue = (maxValue >> 1); |
---|
| 1918 | } |
---|
| 1919 | WRITE_CODE( uiCode, uiLength, "sao_run_diff"); |
---|
| 1920 | } |
---|
[2] | 1921 | #endif |
---|
| 1922 | |
---|
[56] | 1923 | Void TEncCavlc::estBit( estBitsSbacStruct* pcEstBitsCabac, Int width, Int height, TextType eTType ) |
---|
[2] | 1924 | { |
---|
| 1925 | // printf("error : no VLC mode support in this version\n"); |
---|
| 1926 | return; |
---|
| 1927 | } |
---|
| 1928 | |
---|
| 1929 | // ==================================================================================================================== |
---|
| 1930 | // Protected member functions |
---|
| 1931 | // ==================================================================================================================== |
---|
| 1932 | |
---|
| 1933 | Void TEncCavlc::xWriteCode ( UInt uiCode, UInt uiLength ) |
---|
| 1934 | { |
---|
| 1935 | assert ( uiLength > 0 ); |
---|
| 1936 | m_pcBitIf->write( uiCode, uiLength ); |
---|
| 1937 | } |
---|
| 1938 | |
---|
| 1939 | Void TEncCavlc::xWriteUvlc ( UInt uiCode ) |
---|
| 1940 | { |
---|
| 1941 | UInt uiLength = 1; |
---|
| 1942 | UInt uiTemp = ++uiCode; |
---|
[56] | 1943 | |
---|
[2] | 1944 | assert ( uiTemp ); |
---|
[56] | 1945 | |
---|
[2] | 1946 | while( 1 != uiTemp ) |
---|
| 1947 | { |
---|
| 1948 | uiTemp >>= 1; |
---|
| 1949 | uiLength += 2; |
---|
| 1950 | } |
---|
[56] | 1951 | |
---|
| 1952 | //m_pcBitIf->write( uiCode, uiLength ); |
---|
| 1953 | // Take care of cases where uiLength > 32 |
---|
| 1954 | m_pcBitIf->write( 0, uiLength >> 1); |
---|
| 1955 | m_pcBitIf->write( uiCode, (uiLength+1) >> 1); |
---|
[2] | 1956 | } |
---|
| 1957 | |
---|
| 1958 | Void TEncCavlc::xWriteSvlc ( Int iCode ) |
---|
| 1959 | { |
---|
| 1960 | UInt uiCode; |
---|
[56] | 1961 | |
---|
[2] | 1962 | uiCode = xConvertToUInt( iCode ); |
---|
| 1963 | xWriteUvlc( uiCode ); |
---|
| 1964 | } |
---|
| 1965 | |
---|
| 1966 | Void TEncCavlc::xWriteFlag( UInt uiCode ) |
---|
| 1967 | { |
---|
| 1968 | m_pcBitIf->write( uiCode, 1 ); |
---|
| 1969 | } |
---|
| 1970 | |
---|
[56] | 1971 | /** Write PCM alignment bits. |
---|
| 1972 | * \returns Void |
---|
| 1973 | */ |
---|
| 1974 | Void TEncCavlc::xWritePCMAlignZero () |
---|
[2] | 1975 | { |
---|
[56] | 1976 | m_pcBitIf->writeAlignZero(); |
---|
[2] | 1977 | } |
---|
| 1978 | |
---|
| 1979 | Void TEncCavlc::xWriteUnaryMaxSymbol( UInt uiSymbol, UInt uiMaxSymbol ) |
---|
| 1980 | { |
---|
| 1981 | if (uiMaxSymbol == 0) |
---|
| 1982 | { |
---|
| 1983 | return; |
---|
| 1984 | } |
---|
| 1985 | xWriteFlag( uiSymbol ? 1 : 0 ); |
---|
| 1986 | if ( uiSymbol == 0 ) |
---|
| 1987 | { |
---|
| 1988 | return; |
---|
| 1989 | } |
---|
[56] | 1990 | |
---|
[2] | 1991 | Bool bCodeLast = ( uiMaxSymbol > uiSymbol ); |
---|
[56] | 1992 | |
---|
[2] | 1993 | while( --uiSymbol ) |
---|
| 1994 | { |
---|
| 1995 | xWriteFlag( 1 ); |
---|
| 1996 | } |
---|
| 1997 | if( bCodeLast ) |
---|
| 1998 | { |
---|
| 1999 | xWriteFlag( 0 ); |
---|
| 2000 | } |
---|
| 2001 | return; |
---|
| 2002 | } |
---|
| 2003 | |
---|
| 2004 | Void TEncCavlc::xWriteExGolombLevel( UInt uiSymbol ) |
---|
| 2005 | { |
---|
| 2006 | if( uiSymbol ) |
---|
| 2007 | { |
---|
| 2008 | xWriteFlag( 1 ); |
---|
| 2009 | UInt uiCount = 0; |
---|
| 2010 | Bool bNoExGo = (uiSymbol < 13); |
---|
[56] | 2011 | |
---|
[2] | 2012 | while( --uiSymbol && ++uiCount < 13 ) |
---|
| 2013 | { |
---|
| 2014 | xWriteFlag( 1 ); |
---|
| 2015 | } |
---|
| 2016 | if( bNoExGo ) |
---|
| 2017 | { |
---|
| 2018 | xWriteFlag( 0 ); |
---|
| 2019 | } |
---|
| 2020 | else |
---|
| 2021 | { |
---|
| 2022 | xWriteEpExGolomb( uiSymbol, 0 ); |
---|
| 2023 | } |
---|
| 2024 | } |
---|
| 2025 | else |
---|
| 2026 | { |
---|
| 2027 | xWriteFlag( 0 ); |
---|
| 2028 | } |
---|
| 2029 | return; |
---|
| 2030 | } |
---|
| 2031 | |
---|
| 2032 | Void TEncCavlc::xWriteEpExGolomb( UInt uiSymbol, UInt uiCount ) |
---|
| 2033 | { |
---|
| 2034 | while( uiSymbol >= (UInt)(1<<uiCount) ) |
---|
| 2035 | { |
---|
| 2036 | xWriteFlag( 1 ); |
---|
| 2037 | uiSymbol -= 1<<uiCount; |
---|
| 2038 | uiCount ++; |
---|
| 2039 | } |
---|
| 2040 | xWriteFlag( 0 ); |
---|
| 2041 | while( uiCount-- ) |
---|
| 2042 | { |
---|
| 2043 | xWriteFlag( (uiSymbol>>uiCount) & 1 ); |
---|
| 2044 | } |
---|
| 2045 | return; |
---|
| 2046 | } |
---|
| 2047 | |
---|
[56] | 2048 | /** code explicit wp tables |
---|
| 2049 | * \param TComSlice* pcSlice |
---|
| 2050 | * \returns Void |
---|
[2] | 2051 | */ |
---|
[56] | 2052 | Void TEncCavlc::xCodePredWeightTable( TComSlice* pcSlice ) |
---|
[2] | 2053 | { |
---|
[56] | 2054 | wpScalingParam *wp; |
---|
| 2055 | Bool bChroma = true; // color always present in HEVC ? |
---|
| 2056 | Int iNbRef = (pcSlice->getSliceType() == B_SLICE ) ? (2) : (1); |
---|
| 2057 | Bool bDenomCoded = false; |
---|
[2] | 2058 | |
---|
[56] | 2059 | UInt uiMode = 0; |
---|
| 2060 | if ( (pcSlice->getSliceType()==P_SLICE && pcSlice->getPPS()->getUseWP()) || (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPredIdc()==1 && pcSlice->getRefPicListCombinationFlag()==0 ) ) |
---|
| 2061 | uiMode = 1; // explicit |
---|
| 2062 | else if ( pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPredIdc()==2 ) |
---|
| 2063 | uiMode = 2; // implicit (does not use this mode in this syntax) |
---|
| 2064 | if (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPredIdc()==1 && pcSlice->getRefPicListCombinationFlag()) |
---|
| 2065 | uiMode = 3; // combined explicit |
---|
| 2066 | if(uiMode == 1) |
---|
[2] | 2067 | { |
---|
[56] | 2068 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
[2] | 2069 | { |
---|
[56] | 2070 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
| 2071 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
[2] | 2072 | { |
---|
[56] | 2073 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 2074 | if ( !bDenomCoded ) |
---|
[2] | 2075 | { |
---|
[56] | 2076 | Int iDeltaDenom; |
---|
| 2077 | WRITE_UVLC( wp[0].uiLog2WeightDenom, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
[2] | 2078 | |
---|
[56] | 2079 | if( bChroma ) |
---|
[2] | 2080 | { |
---|
[56] | 2081 | iDeltaDenom = (wp[1].uiLog2WeightDenom - wp[0].uiLog2WeightDenom); |
---|
| 2082 | WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
[2] | 2083 | } |
---|
[56] | 2084 | bDenomCoded = true; |
---|
| 2085 | } |
---|
[2] | 2086 | |
---|
[56] | 2087 | WRITE_FLAG( wp[0].bPresentFlag, "luma_weight_lX_flag" ); // u(1): luma_weight_lX_flag |
---|
[2] | 2088 | |
---|
[56] | 2089 | if ( wp[0].bPresentFlag ) |
---|
| 2090 | { |
---|
| 2091 | Int iDeltaWeight = (wp[0].iWeight - (1<<wp[0].uiLog2WeightDenom)); |
---|
| 2092 | WRITE_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_lX |
---|
| 2093 | WRITE_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_lX |
---|
| 2094 | } |
---|
[2] | 2095 | |
---|
[56] | 2096 | if ( bChroma ) |
---|
| 2097 | { |
---|
| 2098 | WRITE_FLAG( wp[1].bPresentFlag, "chroma_weight_lX_flag" ); // u(1): chroma_weight_lX_flag |
---|
[2] | 2099 | |
---|
[56] | 2100 | if ( wp[1].bPresentFlag ) |
---|
[2] | 2101 | { |
---|
[56] | 2102 | for ( Int j=1 ; j<3 ; j++ ) |
---|
[2] | 2103 | { |
---|
[56] | 2104 | Int iDeltaWeight = (wp[j].iWeight - (1<<wp[1].uiLog2WeightDenom)); |
---|
| 2105 | WRITE_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): delta_chroma_weight_lX |
---|
| 2106 | |
---|
| 2107 | Int iDeltaChroma = (wp[j].iOffset + ( ( (g_uiIBDI_MAX>>1)*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) - (g_uiIBDI_MAX>>1)); |
---|
| 2108 | WRITE_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_lX |
---|
[2] | 2109 | } |
---|
| 2110 | } |
---|
| 2111 | } |
---|
| 2112 | } |
---|
| 2113 | } |
---|
| 2114 | } |
---|
[56] | 2115 | else if (uiMode == 3) |
---|
[2] | 2116 | { |
---|
[56] | 2117 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(REF_PIC_LIST_C) ; iRefIdx++ ) |
---|
| 2118 | { |
---|
| 2119 | RefPicList eRefPicList = (RefPicList)pcSlice->getListIdFromIdxOfLC(iRefIdx); |
---|
| 2120 | Int iCombRefIdx = pcSlice->getRefIdxFromIdxOfLC(iRefIdx); |
---|
[2] | 2121 | |
---|
[56] | 2122 | pcSlice->getWpScaling(eRefPicList, iCombRefIdx, 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 |
---|
| 2127 | |
---|
| 2128 | if( bChroma ) |
---|
| 2129 | { |
---|
| 2130 | iDeltaDenom = (wp[1].uiLog2WeightDenom - wp[0].uiLog2WeightDenom); |
---|
| 2131 | WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
| 2132 | } |
---|
| 2133 | bDenomCoded = true; |
---|
[2] | 2134 | } |
---|
| 2135 | |
---|
[56] | 2136 | WRITE_FLAG( wp[0].bPresentFlag, "luma_weight_lc_flag" ); // u(1): luma_weight_lc_flag |
---|
[2] | 2137 | |
---|
[56] | 2138 | if ( wp[0].bPresentFlag ) |
---|
| 2139 | { |
---|
| 2140 | Int iDeltaWeight = (wp[0].iWeight - (1<<wp[0].uiLog2WeightDenom)); |
---|
| 2141 | WRITE_SVLC( iDeltaWeight, "delta_luma_weight_lc" ); // se(v): delta_luma_weight_lc |
---|
| 2142 | WRITE_SVLC( wp[0].iOffset, "luma_offset_lc" ); // se(v): luma_offset_lc |
---|
| 2143 | } |
---|
| 2144 | if ( bChroma ) |
---|
| 2145 | { |
---|
| 2146 | WRITE_FLAG( wp[1].bPresentFlag, "chroma_weight_lc_flag" ); // u(1): luma_weight_lc_flag |
---|
[2] | 2147 | |
---|
[56] | 2148 | if ( wp[1].bPresentFlag ) |
---|
| 2149 | { |
---|
| 2150 | for ( Int j=1 ; j<3 ; j++ ) |
---|
| 2151 | { |
---|
| 2152 | Int iDeltaWeight = (wp[j].iWeight - (1<<wp[1].uiLog2WeightDenom)); |
---|
| 2153 | WRITE_SVLC( iDeltaWeight, "delta_chroma_weight_lc" ); // se(v): delta_chroma_weight_lc |
---|
[2] | 2154 | |
---|
[56] | 2155 | Int iDeltaChroma = (wp[j].iOffset + ( ( (g_uiIBDI_MAX>>1)*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) - (g_uiIBDI_MAX>>1)); |
---|
| 2156 | WRITE_SVLC( iDeltaChroma, "delta_chroma_offset_lc" ); // se(v): delta_chroma_offset_lc |
---|
| 2157 | } |
---|
| 2158 | } |
---|
| 2159 | } |
---|
[2] | 2160 | } |
---|
| 2161 | } |
---|
[56] | 2162 | } |
---|
[2] | 2163 | |
---|
[56] | 2164 | /** code quantization matrix |
---|
| 2165 | * \param scalingList quantization matrix information |
---|
| 2166 | */ |
---|
| 2167 | Void TEncCavlc::codeScalingList( TComScalingList* scalingList ) |
---|
| 2168 | { |
---|
| 2169 | UInt listId,sizeId; |
---|
| 2170 | Bool scalingListPredModeFlag; |
---|
[2] | 2171 | |
---|
[56] | 2172 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 2173 | Int startBit; |
---|
| 2174 | Int startTotalBit; |
---|
| 2175 | startBit = m_pcBitIf->getNumberOfWrittenBits(); |
---|
| 2176 | startTotalBit = m_pcBitIf->getNumberOfWrittenBits(); |
---|
[2] | 2177 | #endif |
---|
| 2178 | |
---|
[56] | 2179 | WRITE_FLAG( scalingList->getScalingListPresentFlag (), "scaling_list_present_flag" ); |
---|
| 2180 | |
---|
| 2181 | if(scalingList->getScalingListPresentFlag () == false) |
---|
[2] | 2182 | { |
---|
[56] | 2183 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 2184 | printf("Header Bit %d\n",m_pcBitIf->getNumberOfWrittenBits()-startBit); |
---|
[2] | 2185 | #endif |
---|
[56] | 2186 | //for each size |
---|
| 2187 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
[2] | 2188 | { |
---|
[56] | 2189 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
[2] | 2190 | { |
---|
[56] | 2191 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 2192 | startBit = m_pcBitIf->getNumberOfWrittenBits(); |
---|
[2] | 2193 | #endif |
---|
[56] | 2194 | scalingListPredModeFlag = scalingList->checkPredMode( sizeId, listId ); |
---|
| 2195 | WRITE_FLAG( scalingListPredModeFlag, "scaling_list_pred_mode_flag" ); |
---|
| 2196 | if(!scalingListPredModeFlag)// Copy Mode |
---|
[2] | 2197 | { |
---|
[56] | 2198 | WRITE_UVLC( (Int)listId - (Int)scalingList->getRefMatrixId (sizeId,listId) - 1, "scaling_list_pred_matrix_id_delta"); |
---|
[2] | 2199 | } |
---|
[56] | 2200 | else// DPCM Mode |
---|
[2] | 2201 | { |
---|
[56] | 2202 | xCodeScalingList(scalingList, sizeId, listId); |
---|
[2] | 2203 | } |
---|
[56] | 2204 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 2205 | printf("Matrix [%d][%d] Bit %d\n",sizeId,listId,m_pcBitIf->getNumberOfWrittenBits() - startBit); |
---|
[2] | 2206 | #endif |
---|
| 2207 | } |
---|
| 2208 | } |
---|
| 2209 | } |
---|
[56] | 2210 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 2211 | else |
---|
[2] | 2212 | { |
---|
[56] | 2213 | printf("Header Bit %d\n",m_pcBitIf->getNumberOfWrittenBits()-startTotalBit); |
---|
[2] | 2214 | } |
---|
[56] | 2215 | printf("Total Bit %d\n",m_pcBitIf->getNumberOfWrittenBits()-startTotalBit); |
---|
| 2216 | #endif |
---|
[2] | 2217 | return; |
---|
| 2218 | } |
---|
[56] | 2219 | /** code DPCM |
---|
| 2220 | * \param scalingList quantization matrix information |
---|
| 2221 | * \param sizeIdc size index |
---|
| 2222 | * \param listIdc list index |
---|
| 2223 | */ |
---|
| 2224 | Void TEncCavlc::xCodeScalingList(TComScalingList* scalingList, UInt sizeId, UInt listId) |
---|
[2] | 2225 | { |
---|
[56] | 2226 | #if SCALING_LIST |
---|
| 2227 | Int coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
| 2228 | UInt* scan = g_auiFrameScanXY [ (sizeId == 0)? 1 : 2]; |
---|
[2] | 2229 | #else |
---|
[56] | 2230 | Int coefNum = (Int)g_scalingListSize[sizeId]; |
---|
| 2231 | UInt* scan = g_auiFrameScanXY [ sizeId + 1]; |
---|
[2] | 2232 | #endif |
---|
[56] | 2233 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
| 2234 | Int data; |
---|
| 2235 | Int *src = scalingList->getScalingListAddress(sizeId, listId); |
---|
| 2236 | #if SCALING_LIST |
---|
| 2237 | if(sizeId > SCALING_LIST_8x8 && scalingList->getUseDefaultScalingMatrixFlag(sizeId,listId)) |
---|
[2] | 2238 | { |
---|
[56] | 2239 | WRITE_SVLC( -8, "scaling_list_dc_coef_minus8"); |
---|
[2] | 2240 | } |
---|
[56] | 2241 | else if(sizeId < SCALING_LIST_16x16 && scalingList->getUseDefaultScalingMatrixFlag(sizeId,listId)) |
---|
[2] | 2242 | { |
---|
[56] | 2243 | WRITE_SVLC( -8, "scaling_list_delta_coef"); |
---|
[2] | 2244 | } |
---|
[56] | 2245 | else |
---|
[2] | 2246 | { |
---|
[56] | 2247 | if( sizeId > SCALING_LIST_8x8 ) |
---|
[2] | 2248 | { |
---|
[56] | 2249 | WRITE_SVLC( scalingList->getScalingListDC(sizeId,listId) - 8, "scaling_list_dc_coef_minus8"); |
---|
[2] | 2250 | } |
---|
[56] | 2251 | for(Int i=0;i<coefNum;i++) |
---|
[2] | 2252 | { |
---|
[56] | 2253 | data = src[scan[i]] - nextCoef; |
---|
| 2254 | nextCoef = src[scan[i]]; |
---|
| 2255 | if(data > 127) |
---|
[2] | 2256 | { |
---|
[56] | 2257 | data = data - 256; |
---|
[2] | 2258 | } |
---|
[56] | 2259 | if(data < -128) |
---|
[2] | 2260 | { |
---|
[56] | 2261 | data = data + 256; |
---|
[2] | 2262 | } |
---|
| 2263 | |
---|
[56] | 2264 | WRITE_SVLC( data, "scaling_list_delta_coef"); |
---|
[2] | 2265 | } |
---|
| 2266 | } |
---|
[56] | 2267 | #else |
---|
| 2268 | for(Int i=0;i<coefNum;i++) |
---|
[2] | 2269 | { |
---|
[56] | 2270 | data = src[scan[i]] - nextCoef; |
---|
| 2271 | nextCoef = src[scan[i]]; |
---|
| 2272 | if(data > 127) |
---|
[2] | 2273 | { |
---|
[56] | 2274 | data = data - 256; |
---|
[2] | 2275 | } |
---|
[56] | 2276 | if(data < -128) |
---|
[2] | 2277 | { |
---|
[56] | 2278 | data = data + 256; |
---|
[2] | 2279 | } |
---|
[56] | 2280 | |
---|
| 2281 | WRITE_SVLC( data, "delta_coef"); |
---|
[2] | 2282 | } |
---|
[56] | 2283 | #endif |
---|
[2] | 2284 | } |
---|
[56] | 2285 | Bool TComScalingList::checkPredMode(UInt sizeId, UInt listId) |
---|
| 2286 | { |
---|
| 2287 | for(Int predListIdx = (Int)listId -1 ; predListIdx >= 0; predListIdx--) |
---|
| 2288 | { |
---|
| 2289 | #if SCALING_LIST |
---|
| 2290 | if( !memcmp(getScalingListAddress(sizeId,listId),getScalingListAddress(sizeId, predListIdx),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
| 2291 | && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == getScalingListDC(sizeId,predListIdx)))) // check DC value |
---|
| 2292 | #else |
---|
| 2293 | if( !memcmp(getScalingListAddress(sizeId,listId),getScalingListAddress(sizeId, predListIdx),sizeof(Int)*(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
[2] | 2294 | #endif |
---|
[56] | 2295 | { |
---|
| 2296 | setRefMatrixId(sizeId, listId, predListIdx); |
---|
| 2297 | return false; |
---|
[2] | 2298 | } |
---|
| 2299 | } |
---|
[56] | 2300 | return true; |
---|
[2] | 2301 | } |
---|
[213] | 2302 | |
---|
| 2303 | #if RWTH_SDC_DLT_B0036 |
---|
| 2304 | Void TEncCavlc::codeSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 2305 | { |
---|
| 2306 | assert(0); |
---|
| 2307 | } |
---|
| 2308 | |
---|
| 2309 | Void TEncCavlc::codeSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment ) |
---|
| 2310 | { |
---|
| 2311 | assert(0); |
---|
| 2312 | } |
---|
| 2313 | |
---|
| 2314 | Void TEncCavlc::codeSDCPredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 2315 | { |
---|
| 2316 | assert(0); |
---|
| 2317 | } |
---|
| 2318 | #endif |
---|
[56] | 2319 | //! \} |
---|