[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 | |
---|
[77] | 377 | #if VIDYO_VPS_INTEGRATION |
---|
| 378 | Void TEncCavlc::codeVPS( TComVPS* pcVPS ) |
---|
| 379 | { |
---|
[100] | 380 | WRITE_CODE( pcVPS->getMaxTLayers() - 1, 3, "max_temporal_layers_minus1" ); |
---|
[77] | 381 | WRITE_CODE( pcVPS->getMaxLayers() - 1, 5, "max_layers_minus1" ); |
---|
| 382 | WRITE_FLAG( pcVPS->getTemporalNestingFlag() - 1, "temporal_id_nesting_flag" ); |
---|
| 383 | WRITE_UVLC( pcVPS->getVPSId(), "video_parameter_set_id" ); |
---|
| 384 | for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
| 385 | { |
---|
| 386 | WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i), "max_dec_pic_buffering[i]" ); |
---|
| 387 | WRITE_UVLC( pcVPS->getNumReorderPics(i), "num_reorder_pics[i]" ); |
---|
| 388 | WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i), "max_latency_increase[i]" ); |
---|
| 389 | } |
---|
| 390 | |
---|
| 391 | WRITE_CODE( 1, 1, "bit_equal_to_one" ); |
---|
| 392 | |
---|
| 393 | if( pcVPS->getMaxLayers() - 1 > 0 ) |
---|
| 394 | { |
---|
| 395 | WRITE_UVLC( pcVPS->getExtensionType(), "extension_type" ); |
---|
| 396 | |
---|
| 397 | for(UInt i=1; i <= pcVPS->getMaxLayers()-1; i++) |
---|
| 398 | { |
---|
| 399 | WRITE_FLAG( pcVPS->getDependentFlag(i), "dependent_flag[i]" ); |
---|
| 400 | if( pcVPS->getDependentFlag(i) ) |
---|
| 401 | { |
---|
| 402 | WRITE_UVLC( i - pcVPS->getDependentLayer(i) - 1, "delta_reference_layer_id_minus1[i]" ); |
---|
| 403 | if( pcVPS->getExtensionType() == VPS_EXTENSION_TYPE_MULTI_VIEW ) |
---|
| 404 | { |
---|
| 405 | WRITE_UVLC( pcVPS->getViewId(i), "view_id[i]" ); |
---|
| 406 | WRITE_FLAG( pcVPS->getDepthFlag(i), "depth_flag[i]" ); |
---|
| 407 | WRITE_SVLC( pcVPS->getViewOrderIdx(i), "view_order_idx[i]" ); |
---|
| 408 | } |
---|
| 409 | |
---|
| 410 | } |
---|
| 411 | } |
---|
| 412 | } |
---|
| 413 | |
---|
| 414 | WRITE_FLAG( 0, "vps_extension_flag" ); |
---|
| 415 | |
---|
| 416 | //future extensions here.. |
---|
| 417 | |
---|
| 418 | return; |
---|
| 419 | } |
---|
| 420 | #endif |
---|
| 421 | |
---|
[56] | 422 | #if HHI_MPI |
---|
| 423 | Void TEncCavlc::codeSPS( TComSPS* pcSPS, Bool bIsDepth ) |
---|
[2] | 424 | #else |
---|
[56] | 425 | Void TEncCavlc::codeSPS( TComSPS* pcSPS ) |
---|
[2] | 426 | #endif |
---|
[56] | 427 | { |
---|
| 428 | #if ENC_DEC_TRACE |
---|
| 429 | xTraceSPSHeader (pcSPS); |
---|
[2] | 430 | #endif |
---|
[56] | 431 | WRITE_CODE( pcSPS->getProfileIdc (), 8, "profile_idc" ); |
---|
| 432 | WRITE_CODE( 0, 8, "reserved_zero_8bits" ); |
---|
| 433 | WRITE_CODE( pcSPS->getLevelIdc (), 8, "level_idc" ); |
---|
| 434 | WRITE_UVLC( pcSPS->getSPSId (), "seq_parameter_set_id" ); |
---|
[77] | 435 | #if VIDYO_VPS_INTEGRATION |
---|
| 436 | WRITE_UVLC( pcSPS->getVPSId (), "video_parameter_set_id" ); |
---|
| 437 | #endif |
---|
[56] | 438 | WRITE_UVLC( pcSPS->getChromaFormatIdc (), "chroma_format_idc" ); |
---|
| 439 | WRITE_CODE( pcSPS->getMaxTLayers() - 1, 3, "max_temporal_layers_minus1" ); |
---|
| 440 | WRITE_UVLC( pcSPS->getPicWidthInLumaSamples (), "pic_width_in_luma_samples" ); |
---|
| 441 | WRITE_UVLC( pcSPS->getPicHeightInLumaSamples(), "pic_height_in_luma_samples" ); |
---|
| 442 | #if PIC_CROPPING |
---|
| 443 | WRITE_FLAG( pcSPS->getPicCroppingFlag(), "pic_cropping_flag" ); |
---|
| 444 | if (pcSPS->getPicCroppingFlag()) |
---|
[2] | 445 | { |
---|
[56] | 446 | WRITE_UVLC( pcSPS->getPicCropLeftOffset(), "pic_crop_left_offset" ); |
---|
| 447 | WRITE_UVLC( pcSPS->getPicCropRightOffset(), "pic_crop_right_offset" ); |
---|
| 448 | WRITE_UVLC( pcSPS->getPicCropTopOffset(), "pic_crop_top_offset" ); |
---|
| 449 | WRITE_UVLC( pcSPS->getPicCropBottomOffset(), "pic_crop_bottom_offset" ); |
---|
[2] | 450 | } |
---|
| 451 | #endif |
---|
| 452 | |
---|
[56] | 453 | #if FULL_NBIT |
---|
| 454 | WRITE_UVLC( pcSPS->getBitDepth() - 8, "bit_depth_luma_minus8" ); |
---|
[2] | 455 | #else |
---|
[56] | 456 | WRITE_UVLC( pcSPS->getBitIncrement(), "bit_depth_luma_minus8" ); |
---|
[2] | 457 | #endif |
---|
[56] | 458 | #if FULL_NBIT |
---|
| 459 | WRITE_UVLC( pcSPS->getBitDepth() - 8, "bit_depth_chroma_minus8" ); |
---|
| 460 | #else |
---|
| 461 | WRITE_UVLC( pcSPS->getBitIncrement(), "bit_depth_chroma_minus8" ); |
---|
[2] | 462 | #endif |
---|
| 463 | |
---|
[56] | 464 | WRITE_FLAG( pcSPS->getUsePCM() ? 1 : 0, "pcm_enabled_flag"); |
---|
[2] | 465 | |
---|
[56] | 466 | if( pcSPS->getUsePCM() ) |
---|
[2] | 467 | { |
---|
[56] | 468 | WRITE_CODE( pcSPS->getPCMBitDepthLuma() - 1, 4, "pcm_bit_depth_luma_minus1" ); |
---|
| 469 | WRITE_CODE( pcSPS->getPCMBitDepthChroma() - 1, 4, "pcm_bit_depth_chroma_minus1" ); |
---|
[2] | 470 | } |
---|
[56] | 471 | |
---|
| 472 | #if LOSSLESS_CODING |
---|
| 473 | WRITE_FLAG( (pcSPS->getUseLossless ()) ? 1 : 0, "qpprime_y_zero_transquant_bypass_flag" ); |
---|
[2] | 474 | #endif |
---|
[56] | 475 | |
---|
| 476 | WRITE_UVLC( pcSPS->getBitsForPOC()-4, "log2_max_pic_order_cnt_lsb_minus4" ); |
---|
| 477 | #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
| 478 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
[2] | 479 | { |
---|
[56] | 480 | WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i), "max_dec_pic_buffering[i]" ); |
---|
| 481 | WRITE_UVLC( pcSPS->getNumReorderPics(i), "num_reorder_pics[i]" ); |
---|
| 482 | WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i), "max_latency_increase[i]" ); |
---|
[2] | 483 | } |
---|
| 484 | #else |
---|
[56] | 485 | WRITE_UVLC( pcSPS->getMaxNumberOfReferencePictures(), "max_num_ref_pics" ); |
---|
| 486 | WRITE_UVLC( pcSPS->getNumReorderFrames(), "num_reorder_frames" ); |
---|
| 487 | WRITE_UVLC(pcSPS->getMaxDecFrameBuffering(), "max_dec_frame_buffering" ); |
---|
| 488 | WRITE_UVLC(pcSPS->getMaxLatencyIncrease(), "max_latency_increase" ); |
---|
[2] | 489 | #endif |
---|
[56] | 490 | assert( pcSPS->getMaxCUWidth() == pcSPS->getMaxCUHeight() ); |
---|
| 491 | |
---|
| 492 | UInt MinCUSize = pcSPS->getMaxCUWidth() >> ( pcSPS->getMaxCUDepth()-g_uiAddCUDepth ); |
---|
| 493 | UInt log2MinCUSize = 0; |
---|
| 494 | while(MinCUSize > 1) |
---|
[2] | 495 | { |
---|
[56] | 496 | MinCUSize >>= 1; |
---|
| 497 | log2MinCUSize++; |
---|
[2] | 498 | } |
---|
| 499 | |
---|
[56] | 500 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
| 501 | WRITE_FLAG( pcSPS->getRestrictedRefPicListsFlag(), "restricted_ref_pic_lists_flag" ); |
---|
| 502 | if( pcSPS->getRestrictedRefPicListsFlag() ) |
---|
[2] | 503 | { |
---|
[56] | 504 | WRITE_FLAG( pcSPS->getListsModificationPresentFlag(), "lists_modification_present_flag" ); |
---|
[2] | 505 | } |
---|
[5] | 506 | #endif |
---|
[56] | 507 | WRITE_UVLC( log2MinCUSize - 3, "log2_min_coding_block_size_minus3" ); |
---|
| 508 | WRITE_UVLC( pcSPS->getMaxCUDepth()-g_uiAddCUDepth, "log2_diff_max_min_coding_block_size" ); |
---|
| 509 | WRITE_UVLC( pcSPS->getQuadtreeTULog2MinSize() - 2, "log2_min_transform_block_size_minus2" ); |
---|
| 510 | WRITE_UVLC( pcSPS->getQuadtreeTULog2MaxSize() - pcSPS->getQuadtreeTULog2MinSize(), "log2_diff_max_min_transform_block_size" ); |
---|
[2] | 511 | |
---|
[56] | 512 | if(log2MinCUSize == 3) |
---|
[2] | 513 | { |
---|
[56] | 514 | xWriteFlag ( (pcSPS->getDisInter4x4()) ? 1 : 0 ); |
---|
[2] | 515 | } |
---|
| 516 | |
---|
[56] | 517 | if( pcSPS->getUsePCM() ) |
---|
[2] | 518 | { |
---|
[56] | 519 | WRITE_UVLC( pcSPS->getPCMLog2MinSize() - 3, "log2_min_pcm_coding_block_size_minus3" ); |
---|
| 520 | WRITE_UVLC( pcSPS->getPCMLog2MaxSize() - pcSPS->getPCMLog2MinSize(), "log2_diff_max_min_pcm_coding_block_size" ); |
---|
[2] | 521 | } |
---|
[56] | 522 | WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthInter() - 1, "max_transform_hierarchy_depth_inter" ); |
---|
| 523 | WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthIntra() - 1, "max_transform_hierarchy_depth_intra" ); |
---|
| 524 | WRITE_FLAG( pcSPS->getScalingListFlag() ? 1 : 0, "scaling_list_enabled_flag" ); |
---|
| 525 | WRITE_FLAG( pcSPS->getUseLMChroma () ? 1 : 0, "chroma_pred_from_luma_enabled_flag" ); |
---|
| 526 | WRITE_FLAG( pcSPS->getUseDF() ? 1 : 0, "deblocking_filter_in_aps_enabled_flag"); |
---|
| 527 | WRITE_FLAG( pcSPS->getLFCrossSliceBoundaryFlag()?1 : 0, "seq_loop_filter_across_slices_enabled_flag"); |
---|
| 528 | WRITE_FLAG( pcSPS->getUseAMP(), "asymmetric_motion_partitions_enabled_flag" ); |
---|
| 529 | WRITE_FLAG( pcSPS->getUseNSQT(), "non_square_quadtree_enabled_flag" ); |
---|
| 530 | WRITE_FLAG( pcSPS->getUseSAO() ? 1 : 0, "sample_adaptive_offset_enabled_flag"); |
---|
| 531 | WRITE_FLAG( pcSPS->getUseALF () ? 1 : 0, "adaptive_loop_filter_enabled_flag"); |
---|
| 532 | #if LCU_SYNTAX_ALF |
---|
| 533 | if(pcSPS->getUseALF()) |
---|
[2] | 534 | { |
---|
[56] | 535 | WRITE_FLAG( (pcSPS->getUseALFCoefInSlice()) ? 1 : 0, "alf_coef_in_slice_flag"); |
---|
[2] | 536 | } |
---|
| 537 | #endif |
---|
| 538 | |
---|
[56] | 539 | if( pcSPS->getUsePCM() ) |
---|
[2] | 540 | { |
---|
[56] | 541 | WRITE_FLAG( pcSPS->getPCMFilterDisableFlag()?1 : 0, "pcm_loop_filter_disable_flag"); |
---|
[2] | 542 | } |
---|
| 543 | |
---|
[56] | 544 | assert( pcSPS->getMaxTLayers() > 0 ); |
---|
[2] | 545 | |
---|
[56] | 546 | WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0, "temporal_id_nesting_flag" ); |
---|
[2] | 547 | |
---|
[56] | 548 | #if RPS_IN_SPS |
---|
| 549 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
| 550 | TComReferencePictureSet* rps; |
---|
[2] | 551 | |
---|
[56] | 552 | WRITE_UVLC(rpsList->getNumberOfReferencePictureSets(), "num_short_term_ref_pic_sets" ); |
---|
| 553 | for(Int i=0; i < rpsList->getNumberOfReferencePictureSets(); i++) |
---|
[2] | 554 | { |
---|
[56] | 555 | rps = rpsList->getReferencePictureSet(i); |
---|
| 556 | codeShortTermRefPicSet(pcSPS,rps); |
---|
| 557 | } |
---|
| 558 | WRITE_FLAG( pcSPS->getLongTermRefsPresent() ? 1 : 0, "long_term_ref_pics_present_flag" ); |
---|
[2] | 559 | #endif |
---|
[56] | 560 | #if !PIC_CROPPING |
---|
| 561 | //!!!KS: Syntax not in WD !!! |
---|
| 562 | |
---|
| 563 | xWriteUvlc ( pcSPS->getPad (0) ); |
---|
| 564 | xWriteUvlc ( pcSPS->getPad (1) ); |
---|
| 565 | #endif |
---|
| 566 | // AMVP mode for each depth |
---|
| 567 | for (Int i = 0; i < pcSPS->getMaxCUDepth(); i++) |
---|
[2] | 568 | { |
---|
[56] | 569 | xWriteFlag( pcSPS->getAMVPMode(i) ? 1 : 0); |
---|
[2] | 570 | } |
---|
| 571 | |
---|
[56] | 572 | #if TILES_WPP_ENTRY_POINT_SIGNALLING |
---|
| 573 | Int tilesOrEntropyCodingSyncIdc = 0; |
---|
| 574 | if ( pcSPS->getNumColumnsMinus1() > 0 || pcSPS->getNumRowsMinus1() > 0) |
---|
[2] | 575 | { |
---|
[56] | 576 | tilesOrEntropyCodingSyncIdc = 1; |
---|
[2] | 577 | } |
---|
[56] | 578 | else if ( pcSPS->getNumSubstreams() > 1 ) |
---|
[2] | 579 | { |
---|
[56] | 580 | tilesOrEntropyCodingSyncIdc = 2; |
---|
[2] | 581 | } |
---|
[56] | 582 | pcSPS->setTilesOrEntropyCodingSyncIdc( tilesOrEntropyCodingSyncIdc ); |
---|
| 583 | WRITE_CODE(tilesOrEntropyCodingSyncIdc, 2, "tiles_or_entropy_coding_sync_idc"); |
---|
[2] | 584 | #endif |
---|
[56] | 585 | |
---|
| 586 | #if TILES_OR_ENTROPY_SYNC_IDC |
---|
| 587 | if(tilesOrEntropyCodingSyncIdc == 1) |
---|
[2] | 588 | { |
---|
| 589 | #endif |
---|
[56] | 590 | WRITE_UVLC( pcSPS->getNumColumnsMinus1(), "num_tile_columns_minus1" ); |
---|
| 591 | WRITE_UVLC( pcSPS->getNumRowsMinus1(), "num_tile_rows_minus1" ); |
---|
| 592 | WRITE_FLAG( pcSPS->getUniformSpacingIdr(), "uniform_spacing_flag" ); |
---|
[2] | 593 | |
---|
[56] | 594 | if( pcSPS->getUniformSpacingIdr()==0 ) |
---|
[2] | 595 | { |
---|
[56] | 596 | for(UInt i=0; i<pcSPS->getNumColumnsMinus1(); i++) |
---|
[2] | 597 | { |
---|
[56] | 598 | WRITE_UVLC( pcSPS->getColumnWidth(i), "column_width" ); |
---|
[2] | 599 | } |
---|
[56] | 600 | for(UInt i=0; i<pcSPS->getNumRowsMinus1(); i++) |
---|
[2] | 601 | { |
---|
[56] | 602 | WRITE_UVLC( pcSPS->getRowHeight(i), "row_height" ); |
---|
[2] | 603 | } |
---|
| 604 | } |
---|
[56] | 605 | |
---|
| 606 | if( pcSPS->getNumColumnsMinus1() !=0 || pcSPS->getNumRowsMinus1() != 0) |
---|
[2] | 607 | { |
---|
[56] | 608 | #if !REMOVE_TILE_DEPENDENCE |
---|
| 609 | WRITE_FLAG( pcSPS->getTileBoundaryIndependenceIdr(), "tile_boundary_independence_flag" ); |
---|
| 610 | if(pcSPS->getTileBoundaryIndependenceIdr() == 1) |
---|
[2] | 611 | { |
---|
[56] | 612 | #endif |
---|
| 613 | WRITE_FLAG( pcSPS->getLFCrossTileBoundaryFlag()?1 : 0, "loop_filter_across_tile_flag"); |
---|
| 614 | #if !REMOVE_TILE_DEPENDENCE |
---|
[2] | 615 | } |
---|
[56] | 616 | #endif |
---|
[2] | 617 | } |
---|
[56] | 618 | #if TILES_OR_ENTROPY_SYNC_IDC |
---|
[2] | 619 | } |
---|
[56] | 620 | #endif |
---|
| 621 | WRITE_FLAG( 1, "sps_extension_flag" ); |
---|
[2] | 622 | |
---|
[56] | 623 | WRITE_FLAG( (pcSPS->getNumberOfUsableInterViewRefs() > 0) ? 1 : 0, "interview_refs_present_flag" ); |
---|
| 624 | if( pcSPS->getNumberOfUsableInterViewRefs() > 0 ) |
---|
[2] | 625 | { |
---|
[56] | 626 | WRITE_UVLC( pcSPS->getNumberOfUsableInterViewRefs() - 1, "num_usable_interview_refs_minus1" ); |
---|
| 627 | |
---|
| 628 | Int prev = 0; |
---|
| 629 | for( Int j = 0 ; j < pcSPS->getNumberOfUsableInterViewRefs(); j++ ) |
---|
| 630 | { |
---|
| 631 | WRITE_UVLC( prev - pcSPS->getUsableInterViewRef( j ) - 1, "delta_usable_interview_ref_minus1" ); |
---|
| 632 | prev = pcSPS->getUsableInterViewRef( j ); |
---|
| 633 | } |
---|
[2] | 634 | } |
---|
| 635 | |
---|
[56] | 636 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
| 637 | WRITE_FLAG( pcSPS->getUseDMM(), "enable_dmm_flag" ); |
---|
[2] | 638 | #endif |
---|
| 639 | |
---|
[56] | 640 | #if HHI_MPI |
---|
| 641 | if( bIsDepth ) |
---|
[2] | 642 | { |
---|
[56] | 643 | WRITE_FLAG( pcSPS->getUseMVI() ? 1 : 0, "use_mvi_flag" ); |
---|
[2] | 644 | } |
---|
| 645 | #endif |
---|
| 646 | |
---|
[56] | 647 | if( pcSPS->getViewId() || pcSPS->isDepth() ) |
---|
[2] | 648 | { |
---|
[56] | 649 | WRITE_FLAG( 0, "base_view_flag" ); |
---|
| 650 | if( pcSPS->isDepth() ) |
---|
[2] | 651 | { |
---|
[56] | 652 | WRITE_FLAG( 1, "depth_flag" ); |
---|
| 653 | WRITE_UVLC( pcSPS->getViewId(), "view_id" ); |
---|
| 654 | WRITE_SVLC( pcSPS->getViewOrderIdx(), "view_order_idx" ); |
---|
[2] | 655 | } |
---|
| 656 | else |
---|
| 657 | { |
---|
[56] | 658 | WRITE_FLAG( 0, "depth_flag" ); |
---|
| 659 | WRITE_UVLC( pcSPS->getViewId() - 1, "view_id_minus1" ); |
---|
| 660 | WRITE_SVLC( pcSPS->getViewOrderIdx(), "view_order_idx" ); |
---|
| 661 | WRITE_UVLC( pcSPS->getCamParPrecision(), "camera_parameter_precision" ); |
---|
| 662 | WRITE_FLAG( pcSPS->hasCamParInSliceHeader() ? 1 : 0, "camera_parameter_in_slice_header" ); |
---|
| 663 | if( !pcSPS->hasCamParInSliceHeader() ) |
---|
| 664 | { |
---|
| 665 | for( UInt uiId = 0; uiId < pcSPS->getViewId(); uiId++ ) |
---|
| 666 | { |
---|
| 667 | WRITE_SVLC( pcSPS->getCodedScale ()[ uiId ], "coded_scale" ); |
---|
| 668 | WRITE_SVLC( pcSPS->getCodedOffset ()[ uiId ], "coded_offset" ); |
---|
| 669 | WRITE_SVLC( pcSPS->getInvCodedScale ()[ uiId ] + pcSPS->getCodedScale ()[ uiId ], "inverse_coded_scale_plus_coded_scale" ); |
---|
| 670 | WRITE_SVLC( pcSPS->getInvCodedOffset()[ uiId ] + pcSPS->getCodedOffset()[ uiId ], "inverse_coded_offset_plus_coded_offset" ); |
---|
| 671 | } |
---|
[2] | 672 | } |
---|
[56] | 673 | #if DEPTH_MAP_GENERATION |
---|
| 674 | WRITE_UVLC( pcSPS->getPredDepthMapGeneration(), "Pdm_generation" ); |
---|
| 675 | if( pcSPS->getPredDepthMapGeneration() ) |
---|
[2] | 676 | { |
---|
[56] | 677 | WRITE_UVLC( pcSPS->getPdmPrecision(), "Pdm_precision" ); |
---|
| 678 | for( UInt uiId = 0; uiId < pcSPS->getViewId(); uiId++ ) |
---|
| 679 | { |
---|
| 680 | WRITE_SVLC( pcSPS->getPdmScaleNomDelta()[ uiId ], "Pdm_scale_nom_delta" ); |
---|
| 681 | WRITE_SVLC( pcSPS->getPdmOffset ()[ uiId ], "Pdm_offset" ); |
---|
| 682 | } |
---|
| 683 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
| 684 | WRITE_UVLC( pcSPS->getMultiviewMvPredMode(), "multi_view_mv_pred_mode" ); |
---|
| 685 | #endif |
---|
| 686 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 687 | WRITE_FLAG ( pcSPS->getMultiviewResPredMode(), "multi_view_residual_pred_mode" ); |
---|
| 688 | #endif |
---|
[2] | 689 | } |
---|
[56] | 690 | #endif |
---|
[2] | 691 | } |
---|
| 692 | } |
---|
[56] | 693 | else |
---|
[2] | 694 | { |
---|
[56] | 695 | WRITE_FLAG( 1, "base_view_flag" ); |
---|
[2] | 696 | } |
---|
[56] | 697 | WRITE_FLAG( 0, "sps_extension2_flag" ); |
---|
| 698 | } |
---|
[2] | 699 | |
---|
[56] | 700 | Void TEncCavlc::writeTileMarker( UInt uiTileIdx, UInt uiBitsUsed ) |
---|
| 701 | { |
---|
| 702 | xWriteCode( uiTileIdx, uiBitsUsed ); |
---|
[2] | 703 | } |
---|
| 704 | |
---|
[56] | 705 | Void TEncCavlc::codeSliceHeader ( TComSlice* pcSlice ) |
---|
[2] | 706 | { |
---|
[56] | 707 | #if ENC_DEC_TRACE |
---|
| 708 | xTraceSliceHeader (pcSlice); |
---|
[2] | 709 | #endif |
---|
| 710 | |
---|
[56] | 711 | // if( nal_ref_idc != 0 ) |
---|
| 712 | // dec_ref_pic_marking( ) |
---|
| 713 | // if( entropy_coding_mode_flag && slice_type != I) |
---|
| 714 | // cabac_init_idc |
---|
| 715 | // first_slice_in_pic_flag |
---|
| 716 | // if( first_slice_in_pic_flag == 0 ) |
---|
| 717 | // slice_address |
---|
| 718 | //calculate number of bits required for slice address |
---|
| 719 | Int maxAddrOuter = pcSlice->getPic()->getNumCUsInFrame(); |
---|
| 720 | Int reqBitsOuter = 0; |
---|
| 721 | while(maxAddrOuter>(1<<reqBitsOuter)) |
---|
[2] | 722 | { |
---|
[56] | 723 | reqBitsOuter++; |
---|
[2] | 724 | } |
---|
[56] | 725 | Int maxAddrInner = pcSlice->getPic()->getNumPartInCU()>>(2); |
---|
| 726 | maxAddrInner = (1<<(pcSlice->getPPS()->getSliceGranularity()<<1)); |
---|
| 727 | Int reqBitsInner = 0; |
---|
| 728 | |
---|
| 729 | while(maxAddrInner>(1<<reqBitsInner)) |
---|
[2] | 730 | { |
---|
[56] | 731 | reqBitsInner++; |
---|
[2] | 732 | } |
---|
[56] | 733 | Int lCUAddress; |
---|
| 734 | Int innerAddress; |
---|
| 735 | if (pcSlice->isNextSlice()) |
---|
[2] | 736 | { |
---|
[56] | 737 | // Calculate slice address |
---|
| 738 | lCUAddress = (pcSlice->getSliceCurStartCUAddr()/pcSlice->getPic()->getNumPartInCU()); |
---|
| 739 | innerAddress = (pcSlice->getSliceCurStartCUAddr()%(pcSlice->getPic()->getNumPartInCU()))>>((pcSlice->getSPS()->getMaxCUDepth()-pcSlice->getPPS()->getSliceGranularity())<<1); |
---|
[2] | 740 | } |
---|
| 741 | else |
---|
| 742 | { |
---|
[56] | 743 | // Calculate slice address |
---|
| 744 | lCUAddress = (pcSlice->getEntropySliceCurStartCUAddr()/pcSlice->getPic()->getNumPartInCU()); |
---|
| 745 | innerAddress = (pcSlice->getEntropySliceCurStartCUAddr()%(pcSlice->getPic()->getNumPartInCU()))>>((pcSlice->getSPS()->getMaxCUDepth()-pcSlice->getPPS()->getSliceGranularity())<<1); |
---|
| 746 | |
---|
[2] | 747 | } |
---|
[56] | 748 | //write slice address |
---|
| 749 | Int address = (pcSlice->getPic()->getPicSym()->getCUOrderMap(lCUAddress) << reqBitsInner) + innerAddress; |
---|
| 750 | WRITE_FLAG( address==0, "first_slice_in_pic_flag" ); |
---|
[152] | 751 | |
---|
| 752 | #if LGE_ILLUCOMP_B0045 |
---|
| 753 | // IC flag is on only first_slice_in_pic |
---|
| 754 | if (address==0) |
---|
| 755 | { |
---|
| 756 | if( pcSlice->getSPS()->getViewId() && !pcSlice->getIsDepth() ) |
---|
| 757 | { |
---|
| 758 | WRITE_FLAG( pcSlice->getApplyIC() ? 1 : 0, "applying IC flag" ); |
---|
| 759 | } |
---|
| 760 | } |
---|
| 761 | #endif |
---|
| 762 | |
---|
[56] | 763 | if(address>0) |
---|
[2] | 764 | { |
---|
[56] | 765 | WRITE_CODE( address, reqBitsOuter+reqBitsInner, "slice_address" ); |
---|
[2] | 766 | } |
---|
| 767 | |
---|
[56] | 768 | WRITE_UVLC( pcSlice->getSliceType(), "slice_type" ); |
---|
| 769 | Bool bEntropySlice = (!pcSlice->isNextSlice()); |
---|
| 770 | WRITE_FLAG( bEntropySlice ? 1 : 0, "lightweight_slice_flag" ); |
---|
| 771 | |
---|
| 772 | if (!bEntropySlice) |
---|
[2] | 773 | { |
---|
[56] | 774 | WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "pic_parameter_set_id" ); |
---|
| 775 | #if H0388 |
---|
| 776 | if( pcSlice->getPPS()->getOutputFlagPresentFlag() ) |
---|
[2] | 777 | { |
---|
[56] | 778 | WRITE_FLAG( pcSlice->getPicOutputFlag() ? 1 : 0, "pic_output_flag" ); |
---|
[2] | 779 | } |
---|
| 780 | #endif |
---|
[56] | 781 | if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_IDR) |
---|
[2] | 782 | { |
---|
[56] | 783 | WRITE_UVLC( 0, "idr_pic_id" ); |
---|
| 784 | WRITE_FLAG( 0, "no_output_of_prior_pics_flag" ); |
---|
[2] | 785 | } |
---|
| 786 | else |
---|
| 787 | { |
---|
[56] | 788 | WRITE_CODE( (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC()))%(1<<pcSlice->getSPS()->getBitsForPOC()), pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb"); |
---|
[77] | 789 | if( pcSlice->getPOC() == 0 && pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDV ) |
---|
| 790 | { |
---|
| 791 | TComReferencePictureSet* rps = pcSlice->getRPS(); |
---|
| 792 | if(pcSlice->getRPSidx() < 0) |
---|
| 793 | { |
---|
| 794 | WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag"); |
---|
| 795 | #if RPS_IN_SPS |
---|
| 796 | codeShortTermRefPicSet(pcSlice->getSPS(), rps); |
---|
| 797 | #else |
---|
| 798 | codeShortTermRefPicSet(pcSlice->getPPS(), rps); |
---|
| 799 | #endif |
---|
| 800 | } |
---|
| 801 | else |
---|
| 802 | { |
---|
| 803 | WRITE_FLAG( 1, "short_term_ref_pic_set_sps_flag"); |
---|
| 804 | WRITE_UVLC( pcSlice->getRPSidx(), "short_term_ref_pic_set_idx" ); |
---|
| 805 | } |
---|
| 806 | #if RPS_IN_SPS |
---|
| 807 | if(pcSlice->getSPS()->getLongTermRefsPresent()) |
---|
| 808 | #else |
---|
| 809 | if(pcSlice->getPPS()->getLongTermRefsPresent()) |
---|
| 810 | #endif |
---|
| 811 | { |
---|
| 812 | WRITE_UVLC( rps->getNumberOfLongtermPictures(), "num_long_term_pics"); |
---|
| 813 | Int maxPocLsb = 1<<pcSlice->getSPS()->getBitsForPOC(); |
---|
| 814 | Int prev = 0; |
---|
| 815 | #if LTRP_MULT |
---|
| 816 | Int prevDeltaPocLt=0; |
---|
| 817 | Int currDeltaPocLt=0; |
---|
| 818 | #endif |
---|
| 819 | for(Int i=rps->getNumberOfPictures()-1 ; i > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; i--) |
---|
| 820 | { |
---|
| 821 | WRITE_UVLC((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb, "delta_poc_lsb_lt"); |
---|
| 822 | |
---|
| 823 | #if LTRP_MULT |
---|
| 824 | currDeltaPocLt=((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb)+prevDeltaPocLt; |
---|
[2] | 825 | |
---|
[77] | 826 | Int deltaMsbCycle=0; |
---|
| 827 | if( (i==(rps->getNumberOfPictures()-1)) ) |
---|
| 828 | { |
---|
| 829 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 830 | } |
---|
| 831 | else if( prevDeltaPocLt!=currDeltaPocLt ) |
---|
| 832 | { |
---|
| 833 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 834 | if( ((prevDeltaPocLt==maxPocLsb-1) && (currDeltaPocLt==maxPocLsb+1)) || ((prevDeltaPocLt==maxPocLsb-2) && (currDeltaPocLt==maxPocLsb))) |
---|
| 835 | { |
---|
| 836 | deltaMsbCycle=deltaMsbCycle-1; |
---|
| 837 | } |
---|
| 838 | } |
---|
| 839 | else |
---|
| 840 | { |
---|
| 841 | deltaMsbCycle=((rps->getDeltaPOC(i+1)-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 842 | } |
---|
| 843 | |
---|
| 844 | if(deltaMsbCycle>=0) |
---|
| 845 | { |
---|
| 846 | WRITE_FLAG( 1, "delta_poc_msb_present_flag"); |
---|
| 847 | WRITE_UVLC(deltaMsbCycle, "delta_poc_msb_cycle_lt_minus1"); |
---|
| 848 | } |
---|
| 849 | else |
---|
| 850 | { |
---|
| 851 | WRITE_FLAG( 0, "delta_poc_msb_present_flag"); |
---|
| 852 | } |
---|
| 853 | prevDeltaPocLt=currDeltaPocLt; |
---|
| 854 | #endif |
---|
| 855 | prev = rps->getDeltaPOC(i); |
---|
| 856 | WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag"); |
---|
| 857 | } |
---|
| 858 | } |
---|
| 859 | } |
---|
| 860 | if( pcSlice->getPOC() != 0 ) |
---|
[2] | 861 | { |
---|
[56] | 862 | TComReferencePictureSet* rps = pcSlice->getRPS(); |
---|
| 863 | if(pcSlice->getRPSidx() < 0) |
---|
| 864 | { |
---|
| 865 | WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag"); |
---|
| 866 | #if RPS_IN_SPS |
---|
| 867 | codeShortTermRefPicSet(pcSlice->getSPS(), rps); |
---|
| 868 | #else |
---|
| 869 | codeShortTermRefPicSet(pcSlice->getPPS(), rps); |
---|
[2] | 870 | #endif |
---|
[56] | 871 | } |
---|
| 872 | else |
---|
[2] | 873 | { |
---|
[56] | 874 | WRITE_FLAG( 1, "short_term_ref_pic_set_sps_flag"); |
---|
| 875 | WRITE_UVLC( pcSlice->getRPSidx(), "short_term_ref_pic_set_idx" ); |
---|
[2] | 876 | } |
---|
[56] | 877 | #if RPS_IN_SPS |
---|
| 878 | if(pcSlice->getSPS()->getLongTermRefsPresent()) |
---|
| 879 | #else |
---|
| 880 | if(pcSlice->getPPS()->getLongTermRefsPresent()) |
---|
[2] | 881 | #endif |
---|
| 882 | { |
---|
[56] | 883 | WRITE_UVLC( rps->getNumberOfLongtermPictures(), "num_long_term_pics"); |
---|
| 884 | Int maxPocLsb = 1<<pcSlice->getSPS()->getBitsForPOC(); |
---|
| 885 | Int prev = 0; |
---|
| 886 | #if LTRP_MULT |
---|
| 887 | Int prevDeltaPocLt=0; |
---|
| 888 | Int currDeltaPocLt=0; |
---|
| 889 | #endif |
---|
| 890 | for(Int i=rps->getNumberOfPictures()-1 ; i > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; i--) |
---|
| 891 | { |
---|
| 892 | WRITE_UVLC((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb, "delta_poc_lsb_lt"); |
---|
| 893 | |
---|
| 894 | #if LTRP_MULT |
---|
| 895 | currDeltaPocLt=((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb)+prevDeltaPocLt; |
---|
| 896 | |
---|
| 897 | Int deltaMsbCycle=0; |
---|
| 898 | if( (i==(rps->getNumberOfPictures()-1)) ) |
---|
| 899 | { |
---|
| 900 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 901 | } |
---|
| 902 | else if( prevDeltaPocLt!=currDeltaPocLt ) |
---|
| 903 | { |
---|
| 904 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 905 | if( ((prevDeltaPocLt==maxPocLsb-1) && (currDeltaPocLt==maxPocLsb+1)) || ((prevDeltaPocLt==maxPocLsb-2) && (currDeltaPocLt==maxPocLsb))) |
---|
| 906 | { |
---|
| 907 | deltaMsbCycle=deltaMsbCycle-1; |
---|
| 908 | } |
---|
| 909 | } |
---|
| 910 | else |
---|
| 911 | { |
---|
| 912 | deltaMsbCycle=((rps->getDeltaPOC(i+1)-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 913 | } |
---|
| 914 | |
---|
| 915 | if(deltaMsbCycle>=0) |
---|
| 916 | { |
---|
| 917 | WRITE_FLAG( 1, "delta_poc_msb_present_flag"); |
---|
| 918 | WRITE_UVLC(deltaMsbCycle, "delta_poc_msb_cycle_lt_minus1"); |
---|
| 919 | } |
---|
| 920 | else |
---|
| 921 | { |
---|
| 922 | WRITE_FLAG( 0, "delta_poc_msb_present_flag"); |
---|
| 923 | } |
---|
| 924 | prevDeltaPocLt=currDeltaPocLt; |
---|
| 925 | #endif |
---|
| 926 | prev = rps->getDeltaPOC(i); |
---|
| 927 | WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag"); |
---|
| 928 | } |
---|
[2] | 929 | } |
---|
| 930 | } |
---|
| 931 | } |
---|
[56] | 932 | |
---|
| 933 | if(pcSlice->getSPS()->getUseSAO() || pcSlice->getSPS()->getUseALF()|| pcSlice->getSPS()->getScalingListFlag() || pcSlice->getSPS()->getUseDF()) |
---|
[2] | 934 | { |
---|
[56] | 935 | if (pcSlice->getSPS()->getUseALF()) |
---|
[2] | 936 | { |
---|
[56] | 937 | #if !LCU_SYNTAX_ALF |
---|
| 938 | if (pcSlice->getAlfEnabledFlag()) |
---|
| 939 | { |
---|
| 940 | assert (pcSlice->getAPS()->getAlfEnabled()); |
---|
| 941 | } |
---|
[2] | 942 | #endif |
---|
[56] | 943 | WRITE_FLAG( pcSlice->getAlfEnabledFlag(), "ALF on/off flag in slice header" ); |
---|
[2] | 944 | } |
---|
[56] | 945 | if (pcSlice->getSPS()->getUseSAO()) |
---|
[2] | 946 | { |
---|
[56] | 947 | #if SAO_UNIT_INTERLEAVING |
---|
| 948 | WRITE_FLAG( pcSlice->getSaoInterleavingFlag(), "SAO interleaving flag" ); |
---|
[2] | 949 | #endif |
---|
[56] | 950 | assert (pcSlice->getSaoEnabledFlag() == pcSlice->getAPS()->getSaoEnabled()); |
---|
| 951 | WRITE_FLAG( pcSlice->getSaoEnabledFlag(), "SAO on/off flag in slice header" ); |
---|
| 952 | #if SAO_UNIT_INTERLEAVING |
---|
| 953 | if (pcSlice->getSaoInterleavingFlag()&&pcSlice->getSaoEnabledFlag() ) |
---|
| 954 | { |
---|
| 955 | WRITE_FLAG( pcSlice->getAPS()->getSaoParam()->bSaoFlag[1], "SAO on/off flag for Cb in slice header" ); |
---|
| 956 | WRITE_FLAG( pcSlice->getAPS()->getSaoParam()->bSaoFlag[2], "SAO on/off flag for Cr in slice header" ); |
---|
| 957 | } |
---|
| 958 | #endif |
---|
[2] | 959 | } |
---|
[56] | 960 | WRITE_UVLC( pcSlice->getAPS()->getAPSID(), "aps_id"); |
---|
[2] | 961 | } |
---|
[56] | 962 | |
---|
| 963 | // we always set num_ref_idx_active_override_flag equal to one. this might be done in a more intelligent way |
---|
| 964 | if (!pcSlice->isIntra()) |
---|
| 965 | { |
---|
| 966 | WRITE_FLAG( 1 , "num_ref_idx_active_override_flag"); |
---|
| 967 | WRITE_CODE( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - 1, 3, "num_ref_idx_l0_active_minus1" ); |
---|
| 968 | } |
---|
[2] | 969 | else |
---|
| 970 | { |
---|
[56] | 971 | pcSlice->setNumRefIdx(REF_PIC_LIST_0, 0); |
---|
[2] | 972 | } |
---|
[56] | 973 | if (pcSlice->isInterB()) |
---|
[2] | 974 | { |
---|
[56] | 975 | WRITE_CODE( pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - 1, 3, "num_ref_idx_l1_active_minus1" ); |
---|
[2] | 976 | } |
---|
[56] | 977 | else |
---|
[2] | 978 | { |
---|
[56] | 979 | pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
[2] | 980 | } |
---|
[56] | 981 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
| 982 | if( pcSlice->getSPS()->getListsModificationPresentFlag() ) |
---|
| 983 | { |
---|
[2] | 984 | #endif |
---|
[56] | 985 | TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); |
---|
| 986 | #if H0137_0138_LIST_MODIFICATION |
---|
| 987 | if( !pcSlice->isIntra() ) |
---|
[2] | 988 | { |
---|
[56] | 989 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0() ? 1 : 0, "ref_pic_list_modification_flag_l0" ); |
---|
| 990 | if (pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0()) |
---|
[2] | 991 | { |
---|
[56] | 992 | Int NumPocTotalCurr = pcSlice->getNumPocTotalCurrMvc(); |
---|
| 993 | if (NumPocTotalCurr > 1) |
---|
[2] | 994 | { |
---|
[56] | 995 | Int length = 1; |
---|
| 996 | NumPocTotalCurr --; |
---|
| 997 | while ( NumPocTotalCurr >>= 1) |
---|
[2] | 998 | { |
---|
[56] | 999 | length ++; |
---|
[2] | 1000 | } |
---|
[56] | 1001 | for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_0 ); i++) |
---|
[2] | 1002 | { |
---|
[56] | 1003 | WRITE_CODE( refPicListModification->getRefPicSetIdxL0(i), length, "list_entry_l0"); |
---|
[2] | 1004 | } |
---|
| 1005 | } |
---|
| 1006 | } |
---|
[56] | 1007 | } |
---|
| 1008 | if(pcSlice->isInterB()) |
---|
| 1009 | { |
---|
| 1010 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1() ? 1 : 0, "ref_pic_list_modification_flag_l1" ); |
---|
| 1011 | if (pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1()) |
---|
[2] | 1012 | { |
---|
[56] | 1013 | Int NumPocTotalCurr = pcSlice->getNumPocTotalCurrMvc(); |
---|
| 1014 | if ( NumPocTotalCurr > 1 ) |
---|
[2] | 1015 | { |
---|
[56] | 1016 | Int length = 1; |
---|
| 1017 | NumPocTotalCurr --; |
---|
| 1018 | while ( NumPocTotalCurr >>= 1) |
---|
[2] | 1019 | { |
---|
[56] | 1020 | length ++; |
---|
[2] | 1021 | } |
---|
[56] | 1022 | for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_1 ); i++) |
---|
[2] | 1023 | { |
---|
[56] | 1024 | WRITE_CODE( refPicListModification->getRefPicSetIdxL1(i), length, "list_entry_l1"); |
---|
[2] | 1025 | } |
---|
| 1026 | } |
---|
| 1027 | } |
---|
| 1028 | } |
---|
| 1029 | #else |
---|
[56] | 1030 | if(!pcSlice->isIntra()) |
---|
[2] | 1031 | { |
---|
[56] | 1032 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0() ? 1 : 0, "ref_pic_list_modification_flag" ); |
---|
| 1033 | for(Int i = 0; i < refPicListModification->getNumberOfRefPicListModificationsL0(); i++) |
---|
[2] | 1034 | { |
---|
[56] | 1035 | WRITE_UVLC( refPicListModification->getListIdcL0(i), "ref_pic_list_modification_idc"); |
---|
| 1036 | WRITE_UVLC( refPicListModification->getRefPicSetIdxL0(i), "ref_pic_set_idx"); |
---|
[2] | 1037 | } |
---|
[56] | 1038 | if(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0()) |
---|
| 1039 | WRITE_UVLC( 3, "ref_pic_list_modification_idc"); |
---|
| 1040 | } |
---|
| 1041 | if(pcSlice->isInterB()) |
---|
| 1042 | { |
---|
| 1043 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1() ? 1 : 0, "ref_pic_list_modification_flag" ); |
---|
| 1044 | for(Int i = 0; i < refPicListModification->getNumberOfRefPicListModificationsL1(); i++) |
---|
[2] | 1045 | { |
---|
[56] | 1046 | WRITE_UVLC( refPicListModification->getListIdcL1(i), "ref_pic_list_modification_idc"); |
---|
| 1047 | WRITE_UVLC( refPicListModification->getRefPicSetIdxL1(i), "ref_pic_set_idx"); |
---|
[2] | 1048 | } |
---|
[56] | 1049 | if(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1()) |
---|
| 1050 | WRITE_UVLC( 3, "ref_pic_list_modification_idc"); |
---|
[2] | 1051 | } |
---|
[56] | 1052 | #endif |
---|
| 1053 | } |
---|
| 1054 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
| 1055 | } |
---|
| 1056 | #endif |
---|
| 1057 | // ref_pic_list_combination( ) |
---|
| 1058 | // maybe move to own function? |
---|
| 1059 | if (pcSlice->isInterB()) |
---|
| 1060 | { |
---|
| 1061 | WRITE_FLAG(pcSlice->getRefPicListCombinationFlag() ? 1 : 0, "ref_pic_list_combination_flag" ); |
---|
| 1062 | if(pcSlice->getRefPicListCombinationFlag()) |
---|
| 1063 | { |
---|
| 1064 | WRITE_UVLC( pcSlice->getNumRefIdx(REF_PIC_LIST_C) - 1, "num_ref_idx lc_active_minus1"); |
---|
| 1065 | |
---|
| 1066 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
| 1067 | if( pcSlice->getSPS()->getListsModificationPresentFlag() ) |
---|
[2] | 1068 | { |
---|
[56] | 1069 | #endif |
---|
| 1070 | WRITE_FLAG( pcSlice->getRefPicListModificationFlagLC() ? 1 : 0, "ref_pic_list_modification_flag_lc" ); |
---|
| 1071 | if(pcSlice->getRefPicListModificationFlagLC()) |
---|
[2] | 1072 | { |
---|
[56] | 1073 | for (UInt i=0;i<pcSlice->getNumRefIdx(REF_PIC_LIST_C);i++) |
---|
| 1074 | { |
---|
| 1075 | WRITE_FLAG( pcSlice->getListIdFromIdxOfLC(i), "pic_from_list_0_flag" ); |
---|
| 1076 | #if H0137_0138_LIST_MODIFICATION |
---|
| 1077 | 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 ) ) |
---|
| 1078 | { |
---|
| 1079 | WRITE_UVLC( pcSlice->getRefIdxFromIdxOfLC(i), "ref_idx_list_curr" ); |
---|
| 1080 | } |
---|
| 1081 | #else |
---|
| 1082 | WRITE_UVLC( pcSlice->getRefIdxFromIdxOfLC(i), "ref_idx_list_curr" ); |
---|
| 1083 | #endif |
---|
| 1084 | } |
---|
[2] | 1085 | } |
---|
[56] | 1086 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
[2] | 1087 | } |
---|
| 1088 | #endif |
---|
| 1089 | } |
---|
| 1090 | } |
---|
[56] | 1091 | |
---|
| 1092 | #if H0111_MVD_L1_ZERO |
---|
| 1093 | if (pcSlice->isInterB()) |
---|
[2] | 1094 | { |
---|
[56] | 1095 | WRITE_FLAG( pcSlice->getMvdL1ZeroFlag() ? 1 : 0, "mvd_l1_zero_flag"); |
---|
[2] | 1096 | } |
---|
| 1097 | #endif |
---|
| 1098 | |
---|
[56] | 1099 | if(pcSlice->getPPS()->getEntropyCodingMode() && !pcSlice->isIntra()) |
---|
[2] | 1100 | { |
---|
[56] | 1101 | #if CABAC_INIT_FLAG |
---|
| 1102 | if (!pcSlice->isIntra() && pcSlice->getPPS()->getCabacInitPresentFlag()) |
---|
[2] | 1103 | { |
---|
[56] | 1104 | SliceType sliceType = pcSlice->getSliceType(); |
---|
| 1105 | Int encCABACTableIdx = pcSlice->getPPS()->getEncCABACTableIdx(); |
---|
| 1106 | Bool encCabacInitFlag = (sliceType!=encCABACTableIdx && encCABACTableIdx!=0) ? true : false; |
---|
| 1107 | pcSlice->setCabacInitFlag( encCabacInitFlag ); |
---|
| 1108 | WRITE_FLAG( encCabacInitFlag?1:0, "cabac_init_flag" ); |
---|
[2] | 1109 | } |
---|
| 1110 | #else |
---|
[56] | 1111 | WRITE_UVLC(pcSlice->getCABACinitIDC(), "cabac_init_idc"); |
---|
[2] | 1112 | #endif |
---|
| 1113 | } |
---|
| 1114 | |
---|
[56] | 1115 | // if( !lightweight_slice_flag ) { |
---|
| 1116 | if (!bEntropySlice) |
---|
[2] | 1117 | { |
---|
[56] | 1118 | Int iCode = pcSlice->getSliceQp() - ( pcSlice->getPPS()->getPicInitQPMinus26() + 26 ); |
---|
| 1119 | WRITE_SVLC( iCode, "slice_qp_delta" ); |
---|
| 1120 | #if DBL_CONTROL |
---|
| 1121 | if (pcSlice->getPPS()->getDeblockingFilterControlPresent()) |
---|
[2] | 1122 | { |
---|
[56] | 1123 | if ( pcSlice->getSPS()->getUseDF() ) |
---|
[2] | 1124 | { |
---|
[56] | 1125 | WRITE_FLAG(pcSlice->getInheritDblParamFromAPS(), "inherit_dbl_param_from_APS_flag"); |
---|
[2] | 1126 | } |
---|
[56] | 1127 | #else |
---|
| 1128 | WRITE_FLAG(pcSlice->getInheritDblParamFromAPS(), "inherit_dbl_param_from_APS_flag"); |
---|
| 1129 | #endif |
---|
| 1130 | if (!pcSlice->getInheritDblParamFromAPS()) |
---|
[2] | 1131 | { |
---|
[56] | 1132 | WRITE_FLAG(pcSlice->getLoopFilterDisable(), "loop_filter_disable"); // should be an IDC |
---|
| 1133 | if(!pcSlice->getLoopFilterDisable()) |
---|
| 1134 | { |
---|
| 1135 | WRITE_SVLC (pcSlice->getLoopFilterBetaOffset(), "beta_offset_div2"); |
---|
| 1136 | WRITE_SVLC (pcSlice->getLoopFilterTcOffset(), "tc_offset_div2"); |
---|
| 1137 | } |
---|
[2] | 1138 | } |
---|
[56] | 1139 | #if DBL_CONTROL |
---|
| 1140 | } |
---|
| 1141 | #endif |
---|
| 1142 | if ( pcSlice->getSliceType() == B_SLICE ) |
---|
| 1143 | { |
---|
| 1144 | WRITE_FLAG( pcSlice->getColDir(), "collocated_from_l0_flag" ); |
---|
| 1145 | } |
---|
[2] | 1146 | |
---|
[56] | 1147 | #if COLLOCATED_REF_IDX |
---|
| 1148 | if ( pcSlice->getSliceType() != I_SLICE && |
---|
| 1149 | ((pcSlice->getColDir()==0 && pcSlice->getNumRefIdx(REF_PIC_LIST_0)>1)|| |
---|
| 1150 | (pcSlice->getColDir()==1 && pcSlice->getNumRefIdx(REF_PIC_LIST_1)>1))) |
---|
| 1151 | { |
---|
| 1152 | WRITE_UVLC( pcSlice->getColRefIdx(), "collocated_ref_idx" ); |
---|
[2] | 1153 | } |
---|
[56] | 1154 | #endif |
---|
| 1155 | |
---|
| 1156 | if ( (pcSlice->getPPS()->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pcSlice->getPPS()->getWPBiPredIdc()==1 && pcSlice->getSliceType()==B_SLICE) ) |
---|
[2] | 1157 | { |
---|
[56] | 1158 | xCodePredWeightTable( pcSlice ); |
---|
[2] | 1159 | } |
---|
| 1160 | } |
---|
| 1161 | |
---|
[56] | 1162 | // !!!! sytnax elements not in the WD !!!! |
---|
| 1163 | if (!bEntropySlice) |
---|
[2] | 1164 | { |
---|
[56] | 1165 | if( pcSlice->getSPS()->hasCamParInSliceHeader() ) |
---|
| 1166 | { |
---|
| 1167 | for( UInt uiId = 0; uiId < pcSlice->getSPS()->getViewId(); uiId++ ) |
---|
| 1168 | { |
---|
| 1169 | WRITE_SVLC( pcSlice->getCodedScale ()[ uiId ], "coded_scale" ); |
---|
| 1170 | WRITE_SVLC( pcSlice->getCodedOffset ()[ uiId ], "coded_offset" ); |
---|
| 1171 | WRITE_SVLC( pcSlice->getInvCodedScale ()[ uiId ] + pcSlice->getCodedScale ()[ uiId ], "inverse_coded_scale_plus_coded_scale" ); |
---|
| 1172 | WRITE_SVLC( pcSlice->getInvCodedOffset()[ uiId ] + pcSlice->getCodedOffset()[ uiId ], "inverse_coded_offset_plus_coded_offset" ); |
---|
| 1173 | } |
---|
| 1174 | } |
---|
[2] | 1175 | } |
---|
[56] | 1176 | |
---|
| 1177 | #if ( HHI_MPI || HHI_INTER_VIEW_MOTION_PRED ) |
---|
| 1178 | #if ( HHI_MPI && HHI_INTER_VIEW_MOTION_PRED ) |
---|
| 1179 | const int iExtraMergeCandidates = ( pcSlice->getSPS()->getUseMVI() || pcSlice->getSPS()->getMultiviewMvPredMode() ) ? 1 : 0; |
---|
| 1180 | #elif HHI_MPI |
---|
| 1181 | const int iExtraMergeCandidates = pcSlice->getSPS()->getUseMVI() ? 1 : 0; |
---|
| 1182 | #else |
---|
| 1183 | const int iExtraMergeCandidates = pcSlice->getSPS()->getMultiviewMvPredMode() ? 1 : 0; |
---|
| 1184 | #endif |
---|
| 1185 | assert(pcSlice->getMaxNumMergeCand()<=(MRG_MAX_NUM_CANDS_SIGNALED+iExtraMergeCandidates)); |
---|
| 1186 | assert(MRG_MAX_NUM_CANDS_SIGNALED<=MRG_MAX_NUM_CANDS); |
---|
| 1187 | WRITE_UVLC(MRG_MAX_NUM_CANDS + iExtraMergeCandidates - pcSlice->getMaxNumMergeCand(), "maxNumMergeCand"); |
---|
[2] | 1188 | #else |
---|
[56] | 1189 | assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS_SIGNALED); |
---|
| 1190 | assert(MRG_MAX_NUM_CANDS_SIGNALED<=MRG_MAX_NUM_CANDS); |
---|
| 1191 | WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSlice->getMaxNumMergeCand(), "maxNumMergeCand"); |
---|
[2] | 1192 | #endif |
---|
| 1193 | } |
---|
| 1194 | |
---|
| 1195 | |
---|
[56] | 1196 | Void TEncCavlc::codeTileMarkerFlag(TComSlice* pcSlice) |
---|
[2] | 1197 | { |
---|
[56] | 1198 | Bool bEntropySlice = (!pcSlice->isNextSlice()); |
---|
| 1199 | if (!bEntropySlice) |
---|
| 1200 | { |
---|
| 1201 | xWriteFlag (pcSlice->getTileMarkerFlag() ? 1 : 0 ); |
---|
| 1202 | } |
---|
[2] | 1203 | } |
---|
| 1204 | |
---|
[56] | 1205 | /** |
---|
| 1206 | - write wavefront substreams sizes for the slice header. |
---|
| 1207 | . |
---|
| 1208 | \param pcSlice Where we find the substream size information. |
---|
| 1209 | */ |
---|
| 1210 | #if TILES_WPP_ENTRY_POINT_SIGNALLING |
---|
| 1211 | Void TEncCavlc::codeTilesWPPEntryPoint( TComSlice* pSlice ) |
---|
[2] | 1212 | { |
---|
[56] | 1213 | Int tilesOrEntropyCodingSyncIdc = pSlice->getSPS()->getTilesOrEntropyCodingSyncIdc(); |
---|
[2] | 1214 | |
---|
[56] | 1215 | if ( tilesOrEntropyCodingSyncIdc == 0 ) |
---|
[2] | 1216 | { |
---|
[56] | 1217 | return; |
---|
[2] | 1218 | } |
---|
| 1219 | |
---|
[56] | 1220 | UInt numEntryPointOffsets = 0, offsetLenMinus1 = 0, maxOffset = 0; |
---|
| 1221 | UInt *entryPointOffset = NULL; |
---|
| 1222 | if (tilesOrEntropyCodingSyncIdc == 1) // tiles |
---|
[2] | 1223 | { |
---|
[56] | 1224 | numEntryPointOffsets = pSlice->getTileLocationCount(); |
---|
| 1225 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
| 1226 | for (Int idx=0; idx<pSlice->getTileLocationCount(); idx++) |
---|
[2] | 1227 | { |
---|
[56] | 1228 | if ( idx == 0 ) |
---|
[2] | 1229 | { |
---|
[56] | 1230 | entryPointOffset [ idx ] = pSlice->getTileLocation( 0 ); |
---|
[2] | 1231 | } |
---|
[56] | 1232 | else |
---|
[2] | 1233 | { |
---|
[56] | 1234 | entryPointOffset [ idx ] = pSlice->getTileLocation( idx ) - pSlice->getTileLocation( idx-1 ); |
---|
[2] | 1235 | } |
---|
| 1236 | |
---|
[56] | 1237 | if ( entryPointOffset[ idx ] > maxOffset ) |
---|
| 1238 | { |
---|
| 1239 | maxOffset = entryPointOffset[ idx ]; |
---|
| 1240 | } |
---|
[2] | 1241 | } |
---|
| 1242 | } |
---|
[56] | 1243 | else if (tilesOrEntropyCodingSyncIdc == 2) // wavefront |
---|
[2] | 1244 | { |
---|
[56] | 1245 | Int numZeroSubstreamsAtEndOfSlice = 0; |
---|
| 1246 | UInt* pSubstreamSizes = pSlice->getSubstreamSizes(); |
---|
| 1247 | // Find number of zero substreams at the end of slice |
---|
| 1248 | for (Int idx=pSlice->getPPS()->getNumSubstreams()-2; idx>=0; idx--) |
---|
[2] | 1249 | { |
---|
[56] | 1250 | if ( pSubstreamSizes[ idx ] == 0 ) |
---|
[2] | 1251 | { |
---|
[56] | 1252 | numZeroSubstreamsAtEndOfSlice++; |
---|
[2] | 1253 | } |
---|
[56] | 1254 | else |
---|
[2] | 1255 | { |
---|
[56] | 1256 | break; |
---|
[2] | 1257 | } |
---|
| 1258 | } |
---|
[56] | 1259 | numEntryPointOffsets = pSlice->getPPS()->getNumSubstreams() - 1 - numZeroSubstreamsAtEndOfSlice; |
---|
| 1260 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
| 1261 | for (Int idx=0; idx<numEntryPointOffsets; idx++) |
---|
[2] | 1262 | { |
---|
[56] | 1263 | entryPointOffset[ idx ] = ( pSubstreamSizes[ idx ] >> 3 ) ; |
---|
| 1264 | if ( entryPointOffset[ idx ] > maxOffset ) |
---|
[2] | 1265 | { |
---|
[56] | 1266 | maxOffset = entryPointOffset[ idx ]; |
---|
[2] | 1267 | } |
---|
| 1268 | } |
---|
[56] | 1269 | } |
---|
[2] | 1270 | |
---|
[56] | 1271 | 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] | 1272 | |
---|
[56] | 1273 | // Determine number of bits "offsetLenMinus1+1" required for entry point information |
---|
| 1274 | offsetLenMinus1 = 0; |
---|
| 1275 | while (1) |
---|
| 1276 | { |
---|
| 1277 | if (maxOffset >= (1 << offsetLenMinus1) ) |
---|
| 1278 | { |
---|
| 1279 | offsetLenMinus1++; |
---|
| 1280 | if ( offsetLenMinus1 > 32 ) |
---|
[2] | 1281 | { |
---|
[56] | 1282 | FATAL_ERROR_0("exceeded 32-bits", -1); |
---|
[2] | 1283 | } |
---|
| 1284 | } |
---|
[56] | 1285 | else |
---|
[2] | 1286 | { |
---|
[56] | 1287 | break; |
---|
[2] | 1288 | } |
---|
| 1289 | } |
---|
| 1290 | |
---|
[56] | 1291 | WRITE_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); |
---|
| 1292 | if (numEntryPointOffsets>0) |
---|
[2] | 1293 | { |
---|
[56] | 1294 | WRITE_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
[2] | 1295 | } |
---|
[56] | 1296 | |
---|
| 1297 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
[2] | 1298 | { |
---|
[56] | 1299 | if ( idx == 0 ) |
---|
| 1300 | { |
---|
| 1301 | // Adding sizes of NALU header and slice header information to entryPointOffset[ 0 ] |
---|
| 1302 | Int bitDistFromNALUHdrStart = m_pcBitIf->getNumberOfWrittenBits() + 16; |
---|
| 1303 | entryPointOffset[ idx ] += ( bitDistFromNALUHdrStart + numEntryPointOffsets*(offsetLenMinus1+1) ) >> 3; |
---|
| 1304 | } |
---|
| 1305 | WRITE_CODE(entryPointOffset[ idx ], offsetLenMinus1+1, "entry_point_offset"); |
---|
[2] | 1306 | } |
---|
| 1307 | |
---|
[56] | 1308 | delete [] entryPointOffset; |
---|
[2] | 1309 | } |
---|
[56] | 1310 | #else |
---|
| 1311 | Void TEncCavlc::codeSliceHeaderSubstreamTable( TComSlice* pcSlice ) |
---|
| 1312 | { |
---|
| 1313 | UInt uiNumSubstreams = pcSlice->getPPS()->getNumSubstreams(); |
---|
| 1314 | UInt*puiSubstreamSizes = pcSlice->getSubstreamSizes(); |
---|
[2] | 1315 | |
---|
[56] | 1316 | // Write header information for all substreams except the last. |
---|
| 1317 | for (UInt ui = 0; ui+1 < uiNumSubstreams; ui++) |
---|
[2] | 1318 | { |
---|
[56] | 1319 | UInt uiNumbits = puiSubstreamSizes[ui]; |
---|
[2] | 1320 | |
---|
[56] | 1321 | //the 2 first bits are used to give the size of the header |
---|
| 1322 | if ( uiNumbits < (1<<8) ) |
---|
[2] | 1323 | { |
---|
[56] | 1324 | xWriteCode(0, 2 ); |
---|
| 1325 | xWriteCode(uiNumbits, 8 ); |
---|
[2] | 1326 | } |
---|
[56] | 1327 | else if ( uiNumbits < (1<<16) ) |
---|
| 1328 | { |
---|
| 1329 | xWriteCode(1, 2 ); |
---|
| 1330 | xWriteCode(uiNumbits, 16 ); |
---|
| 1331 | } |
---|
| 1332 | else if ( uiNumbits < (1<<24) ) |
---|
| 1333 | { |
---|
| 1334 | xWriteCode(2, 2 ); |
---|
| 1335 | xWriteCode(uiNumbits, 24 ); |
---|
| 1336 | } |
---|
| 1337 | else if ( uiNumbits < (1<<31) ) |
---|
| 1338 | { |
---|
| 1339 | xWriteCode(3, 2 ); |
---|
| 1340 | xWriteCode(uiNumbits, 32 ); |
---|
| 1341 | } |
---|
| 1342 | else |
---|
| 1343 | { |
---|
| 1344 | printf("Error in codeSliceHeaderTable\n"); |
---|
| 1345 | exit(-1); |
---|
| 1346 | } |
---|
[2] | 1347 | } |
---|
| 1348 | } |
---|
[56] | 1349 | #endif |
---|
[2] | 1350 | |
---|
[56] | 1351 | Void TEncCavlc::codeTerminatingBit ( UInt uilsLast ) |
---|
[2] | 1352 | { |
---|
[56] | 1353 | } |
---|
[2] | 1354 | |
---|
[56] | 1355 | Void TEncCavlc::codeSliceFinish () |
---|
| 1356 | { |
---|
| 1357 | } |
---|
[2] | 1358 | |
---|
[56] | 1359 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
| 1360 | Void TEncCavlc::codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Int iNum ) |
---|
[2] | 1361 | #else |
---|
[56] | 1362 | Void TEncCavlc::codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
[2] | 1363 | #endif |
---|
[56] | 1364 | { |
---|
| 1365 | assert(0); |
---|
| 1366 | } |
---|
[2] | 1367 | |
---|
[56] | 1368 | Void TEncCavlc::codePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1369 | { |
---|
| 1370 | assert(0); |
---|
| 1371 | } |
---|
[2] | 1372 | |
---|
[56] | 1373 | Void TEncCavlc::codePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1374 | { |
---|
| 1375 | assert(0); |
---|
| 1376 | } |
---|
[2] | 1377 | |
---|
[56] | 1378 | Void TEncCavlc::codeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1379 | { |
---|
| 1380 | assert(0); |
---|
| 1381 | } |
---|
[2] | 1382 | |
---|
[56] | 1383 | Void TEncCavlc::codeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1384 | { |
---|
| 1385 | assert(0); |
---|
| 1386 | } |
---|
[2] | 1387 | |
---|
[56] | 1388 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 1389 | Void |
---|
| 1390 | TEncCavlc::codeResPredFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1391 | { |
---|
| 1392 | assert(0); |
---|
| 1393 | } |
---|
[2] | 1394 | #endif |
---|
| 1395 | |
---|
[56] | 1396 | Void TEncCavlc::codeAlfCtrlFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1397 | { |
---|
| 1398 | if (!m_bAlfCtrl) |
---|
| 1399 | { |
---|
| 1400 | return; |
---|
[2] | 1401 | } |
---|
[56] | 1402 | |
---|
| 1403 | if( pcCU->getDepth(uiAbsPartIdx) > m_uiMaxAlfCtrlDepth && !pcCU->isFirstAbsZorderIdxInDepth(uiAbsPartIdx, m_uiMaxAlfCtrlDepth)) |
---|
| 1404 | { |
---|
| 1405 | return; |
---|
| 1406 | } |
---|
| 1407 | |
---|
| 1408 | // get context function is here |
---|
| 1409 | UInt uiSymbol = pcCU->getAlfCtrlFlag( uiAbsPartIdx ) ? 1 : 0; |
---|
| 1410 | |
---|
| 1411 | xWriteFlag( uiSymbol ); |
---|
| 1412 | } |
---|
[2] | 1413 | |
---|
[56] | 1414 | Void TEncCavlc::codeApsExtensionFlag () |
---|
| 1415 | { |
---|
| 1416 | WRITE_FLAG(0, "aps_extension_flag"); |
---|
[2] | 1417 | } |
---|
| 1418 | |
---|
[56] | 1419 | Void TEncCavlc::codeAlfCtrlDepth() |
---|
| 1420 | { |
---|
| 1421 | if (!m_bAlfCtrl) |
---|
[2] | 1422 | { |
---|
[56] | 1423 | return; |
---|
[2] | 1424 | } |
---|
[56] | 1425 | |
---|
| 1426 | UInt uiDepth = m_uiMaxAlfCtrlDepth; |
---|
| 1427 | |
---|
| 1428 | xWriteUvlc(uiDepth); |
---|
| 1429 | } |
---|
[2] | 1430 | |
---|
[56] | 1431 | Void TEncCavlc::codeInterModeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiEncMode ) |
---|
| 1432 | { |
---|
| 1433 | assert(0); |
---|
| 1434 | } |
---|
[2] | 1435 | |
---|
[56] | 1436 | Void TEncCavlc::codeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1437 | { |
---|
| 1438 | assert(0); |
---|
| 1439 | } |
---|
[2] | 1440 | |
---|
[152] | 1441 | #if LGE_ILLUCOMP_B0045 |
---|
| 1442 | Void TEncCavlc::codeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1443 | { |
---|
| 1444 | assert(0); |
---|
| 1445 | } |
---|
| 1446 | #endif |
---|
| 1447 | |
---|
[56] | 1448 | Void TEncCavlc::codeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1449 | { |
---|
| 1450 | assert(0); |
---|
| 1451 | } |
---|
[2] | 1452 | |
---|
[56] | 1453 | Void TEncCavlc::codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) |
---|
| 1454 | { |
---|
| 1455 | assert(0); |
---|
| 1456 | } |
---|
[2] | 1457 | |
---|
[56] | 1458 | Void TEncCavlc::codeQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) |
---|
| 1459 | { |
---|
| 1460 | assert(0); |
---|
| 1461 | } |
---|
[2] | 1462 | |
---|
[56] | 1463 | Void TEncCavlc::codeQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1464 | { |
---|
| 1465 | assert(0); |
---|
| 1466 | } |
---|
[2] | 1467 | |
---|
[56] | 1468 | #if BURST_IPCM |
---|
| 1469 | /** Code I_PCM information. |
---|
| 1470 | * \param pcCU pointer to CU |
---|
| 1471 | * \param uiAbsPartIdx CU index |
---|
| 1472 | * \param numIPCM the number of succesive IPCM blocks with the same size |
---|
| 1473 | * \param firstIPCMFlag |
---|
| 1474 | * \returns Void |
---|
| 1475 | */ |
---|
| 1476 | Void TEncCavlc::codeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, Int numIPCM, Bool firstIPCMFlag) |
---|
| 1477 | { |
---|
| 1478 | assert(0); |
---|
| 1479 | } |
---|
[2] | 1480 | #else |
---|
[56] | 1481 | /** Code I_PCM information. |
---|
| 1482 | * \param pcCU pointer to CU |
---|
| 1483 | * \param uiAbsPartIdx CU index |
---|
| 1484 | * \returns Void |
---|
| 1485 | * |
---|
| 1486 | * If I_PCM flag indicates that the CU is I_PCM, code its PCM alignment bits and codes. |
---|
| 1487 | */ |
---|
| 1488 | Void TEncCavlc::codeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx) |
---|
| 1489 | { |
---|
| 1490 | UInt uiIPCM = (pcCU->getIPCMFlag(uiAbsPartIdx) == true)? 1 : 0; |
---|
[2] | 1491 | |
---|
[56] | 1492 | xWriteFlag(uiIPCM); |
---|
[2] | 1493 | |
---|
[56] | 1494 | if (uiIPCM) |
---|
[2] | 1495 | { |
---|
[56] | 1496 | xWritePCMAlignZero(); |
---|
[2] | 1497 | |
---|
[56] | 1498 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
| 1499 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
| 1500 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
[2] | 1501 | |
---|
[56] | 1502 | Pel* piPCMSample; |
---|
| 1503 | UInt uiWidth; |
---|
| 1504 | UInt uiHeight; |
---|
| 1505 | UInt uiSampleBits; |
---|
| 1506 | UInt uiX, uiY; |
---|
[2] | 1507 | |
---|
[56] | 1508 | piPCMSample = pcCU->getPCMSampleY() + uiLumaOffset; |
---|
| 1509 | uiWidth = pcCU->getWidth(uiAbsPartIdx); |
---|
| 1510 | uiHeight = pcCU->getHeight(uiAbsPartIdx); |
---|
| 1511 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
| 1512 | |
---|
| 1513 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
[2] | 1514 | { |
---|
[56] | 1515 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
[2] | 1516 | { |
---|
[56] | 1517 | UInt uiSample = piPCMSample[uiX]; |
---|
| 1518 | |
---|
| 1519 | xWriteCode(uiSample, uiSampleBits); |
---|
[2] | 1520 | } |
---|
[56] | 1521 | piPCMSample += uiWidth; |
---|
[2] | 1522 | } |
---|
| 1523 | |
---|
[56] | 1524 | piPCMSample = pcCU->getPCMSampleCb() + uiChromaOffset; |
---|
| 1525 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
| 1526 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
| 1527 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
| 1528 | |
---|
| 1529 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
[2] | 1530 | { |
---|
[56] | 1531 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
[2] | 1532 | { |
---|
[56] | 1533 | UInt uiSample = piPCMSample[uiX]; |
---|
| 1534 | |
---|
| 1535 | xWriteCode(uiSample, uiSampleBits); |
---|
[2] | 1536 | } |
---|
[56] | 1537 | piPCMSample += uiWidth; |
---|
[2] | 1538 | } |
---|
| 1539 | |
---|
[56] | 1540 | piPCMSample = pcCU->getPCMSampleCr() + uiChromaOffset; |
---|
| 1541 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
| 1542 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
| 1543 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
| 1544 | |
---|
| 1545 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
[2] | 1546 | { |
---|
[56] | 1547 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
| 1548 | { |
---|
| 1549 | UInt uiSample = piPCMSample[uiX]; |
---|
| 1550 | |
---|
| 1551 | xWriteCode(uiSample, uiSampleBits); |
---|
| 1552 | } |
---|
| 1553 | piPCMSample += uiWidth; |
---|
[2] | 1554 | } |
---|
[56] | 1555 | } |
---|
| 1556 | } |
---|
[2] | 1557 | #endif |
---|
| 1558 | |
---|
[56] | 1559 | Void TEncCavlc::codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1560 | { |
---|
| 1561 | assert(0); |
---|
| 1562 | } |
---|
[2] | 1563 | |
---|
[56] | 1564 | Void TEncCavlc::codeIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1565 | { |
---|
| 1566 | assert(0); |
---|
[2] | 1567 | } |
---|
| 1568 | |
---|
[56] | 1569 | Void TEncCavlc::codeInterDir( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
[2] | 1570 | { |
---|
[56] | 1571 | assert(0); |
---|
| 1572 | } |
---|
[2] | 1573 | |
---|
[56] | 1574 | Void TEncCavlc::codeRefFrmIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
| 1575 | { |
---|
| 1576 | assert(0); |
---|
[2] | 1577 | } |
---|
| 1578 | |
---|
[56] | 1579 | Void TEncCavlc::codeMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
[2] | 1580 | { |
---|
[56] | 1581 | assert(0); |
---|
[2] | 1582 | } |
---|
| 1583 | |
---|
[56] | 1584 | Void TEncCavlc::codeDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1585 | { |
---|
| 1586 | Int iDQp = pcCU->getQP( uiAbsPartIdx ) - pcCU->getRefQP( uiAbsPartIdx ); |
---|
| 1587 | |
---|
| 1588 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1589 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
| 1590 | iDQp = (iDQp + 78 + qpBdOffsetY + (qpBdOffsetY/2)) % (52 + qpBdOffsetY) - 26 - (qpBdOffsetY/2); |
---|
| 1591 | #endif |
---|
| 1592 | |
---|
| 1593 | xWriteSvlc( iDQp ); |
---|
| 1594 | |
---|
| 1595 | return; |
---|
| 1596 | } |
---|
| 1597 | |
---|
| 1598 | Void TEncCavlc::codeCoeffNxN ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) |
---|
| 1599 | { |
---|
| 1600 | assert(0); |
---|
| 1601 | } |
---|
| 1602 | |
---|
| 1603 | Void TEncCavlc::codeAlfFlag( UInt uiCode ) |
---|
| 1604 | { |
---|
| 1605 | xWriteFlag( uiCode ); |
---|
| 1606 | } |
---|
| 1607 | |
---|
[2] | 1608 | Void TEncCavlc::codeAlfCtrlFlag( UInt uiSymbol ) |
---|
| 1609 | { |
---|
| 1610 | xWriteFlag( uiSymbol ); |
---|
| 1611 | } |
---|
| 1612 | |
---|
| 1613 | Void TEncCavlc::codeAlfUvlc( UInt uiCode ) |
---|
| 1614 | { |
---|
| 1615 | xWriteUvlc( uiCode ); |
---|
| 1616 | } |
---|
| 1617 | |
---|
| 1618 | Void TEncCavlc::codeAlfSvlc( Int iCode ) |
---|
| 1619 | { |
---|
| 1620 | xWriteSvlc( iCode ); |
---|
| 1621 | } |
---|
[56] | 1622 | #if LCU_SYNTAX_ALF |
---|
| 1623 | /** Code the fixed length code (smaller than one max value) in OSALF |
---|
| 1624 | * \param idx: coded value |
---|
| 1625 | * \param maxValue: max value |
---|
| 1626 | */ |
---|
| 1627 | Void TEncCavlc::codeAlfFixedLengthIdx( UInt idx, UInt maxValue) |
---|
[2] | 1628 | { |
---|
[56] | 1629 | UInt length = 0; |
---|
| 1630 | assert(idx<=maxValue); |
---|
[2] | 1631 | |
---|
[56] | 1632 | UInt temp = maxValue; |
---|
| 1633 | for(UInt i=0; i<32; i++) |
---|
| 1634 | { |
---|
| 1635 | if(temp&0x1) |
---|
| 1636 | { |
---|
| 1637 | length = i+1; |
---|
| 1638 | } |
---|
| 1639 | temp = (temp >> 1); |
---|
| 1640 | } |
---|
| 1641 | |
---|
| 1642 | if(length) |
---|
| 1643 | { |
---|
| 1644 | xWriteCode( idx, length ); |
---|
| 1645 | } |
---|
| 1646 | } |
---|
| 1647 | #endif |
---|
| 1648 | |
---|
| 1649 | Void TEncCavlc::codeSaoFlag( UInt uiCode ) |
---|
| 1650 | { |
---|
[2] | 1651 | xWriteFlag( uiCode ); |
---|
| 1652 | } |
---|
| 1653 | |
---|
[56] | 1654 | Void TEncCavlc::codeSaoUvlc( UInt uiCode ) |
---|
[2] | 1655 | { |
---|
| 1656 | xWriteUvlc( uiCode ); |
---|
| 1657 | } |
---|
| 1658 | |
---|
[56] | 1659 | Void TEncCavlc::codeSaoSvlc( Int iCode ) |
---|
[2] | 1660 | { |
---|
| 1661 | xWriteSvlc( iCode ); |
---|
| 1662 | } |
---|
[56] | 1663 | #if SAO_UNIT_INTERLEAVING |
---|
| 1664 | /** Code SAO run. |
---|
| 1665 | * \param uiCode |
---|
| 1666 | * \param maxValue |
---|
| 1667 | */ |
---|
| 1668 | Void TEncCavlc::codeSaoRun( UInt uiCode, UInt maxValue) |
---|
| 1669 | { |
---|
| 1670 | UInt uiLength = 0; |
---|
| 1671 | if (!maxValue) |
---|
| 1672 | { |
---|
| 1673 | return; |
---|
| 1674 | } |
---|
| 1675 | assert(uiCode<=maxValue); |
---|
[2] | 1676 | |
---|
[56] | 1677 | for(UInt i=0; i<32; i++) |
---|
| 1678 | { |
---|
| 1679 | if(maxValue&0x1) |
---|
| 1680 | { |
---|
| 1681 | uiLength = i+1; |
---|
| 1682 | } |
---|
| 1683 | maxValue = (maxValue >> 1); |
---|
| 1684 | } |
---|
| 1685 | WRITE_CODE( uiCode, uiLength, "sao_run_diff"); |
---|
| 1686 | } |
---|
[2] | 1687 | #endif |
---|
| 1688 | |
---|
[56] | 1689 | Void TEncCavlc::estBit( estBitsSbacStruct* pcEstBitsCabac, Int width, Int height, TextType eTType ) |
---|
[2] | 1690 | { |
---|
| 1691 | // printf("error : no VLC mode support in this version\n"); |
---|
| 1692 | return; |
---|
| 1693 | } |
---|
| 1694 | |
---|
| 1695 | // ==================================================================================================================== |
---|
| 1696 | // Protected member functions |
---|
| 1697 | // ==================================================================================================================== |
---|
| 1698 | |
---|
| 1699 | Void TEncCavlc::xWriteCode ( UInt uiCode, UInt uiLength ) |
---|
| 1700 | { |
---|
| 1701 | assert ( uiLength > 0 ); |
---|
| 1702 | m_pcBitIf->write( uiCode, uiLength ); |
---|
| 1703 | } |
---|
| 1704 | |
---|
| 1705 | Void TEncCavlc::xWriteUvlc ( UInt uiCode ) |
---|
| 1706 | { |
---|
| 1707 | UInt uiLength = 1; |
---|
| 1708 | UInt uiTemp = ++uiCode; |
---|
[56] | 1709 | |
---|
[2] | 1710 | assert ( uiTemp ); |
---|
[56] | 1711 | |
---|
[2] | 1712 | while( 1 != uiTemp ) |
---|
| 1713 | { |
---|
| 1714 | uiTemp >>= 1; |
---|
| 1715 | uiLength += 2; |
---|
| 1716 | } |
---|
[56] | 1717 | |
---|
| 1718 | //m_pcBitIf->write( uiCode, uiLength ); |
---|
| 1719 | // Take care of cases where uiLength > 32 |
---|
| 1720 | m_pcBitIf->write( 0, uiLength >> 1); |
---|
| 1721 | m_pcBitIf->write( uiCode, (uiLength+1) >> 1); |
---|
[2] | 1722 | } |
---|
| 1723 | |
---|
| 1724 | Void TEncCavlc::xWriteSvlc ( Int iCode ) |
---|
| 1725 | { |
---|
| 1726 | UInt uiCode; |
---|
[56] | 1727 | |
---|
[2] | 1728 | uiCode = xConvertToUInt( iCode ); |
---|
| 1729 | xWriteUvlc( uiCode ); |
---|
| 1730 | } |
---|
| 1731 | |
---|
| 1732 | Void TEncCavlc::xWriteFlag( UInt uiCode ) |
---|
| 1733 | { |
---|
| 1734 | m_pcBitIf->write( uiCode, 1 ); |
---|
| 1735 | } |
---|
| 1736 | |
---|
[56] | 1737 | /** Write PCM alignment bits. |
---|
| 1738 | * \returns Void |
---|
| 1739 | */ |
---|
| 1740 | Void TEncCavlc::xWritePCMAlignZero () |
---|
[2] | 1741 | { |
---|
[56] | 1742 | m_pcBitIf->writeAlignZero(); |
---|
[2] | 1743 | } |
---|
| 1744 | |
---|
| 1745 | Void TEncCavlc::xWriteUnaryMaxSymbol( UInt uiSymbol, UInt uiMaxSymbol ) |
---|
| 1746 | { |
---|
| 1747 | if (uiMaxSymbol == 0) |
---|
| 1748 | { |
---|
| 1749 | return; |
---|
| 1750 | } |
---|
| 1751 | xWriteFlag( uiSymbol ? 1 : 0 ); |
---|
| 1752 | if ( uiSymbol == 0 ) |
---|
| 1753 | { |
---|
| 1754 | return; |
---|
| 1755 | } |
---|
[56] | 1756 | |
---|
[2] | 1757 | Bool bCodeLast = ( uiMaxSymbol > uiSymbol ); |
---|
[56] | 1758 | |
---|
[2] | 1759 | while( --uiSymbol ) |
---|
| 1760 | { |
---|
| 1761 | xWriteFlag( 1 ); |
---|
| 1762 | } |
---|
| 1763 | if( bCodeLast ) |
---|
| 1764 | { |
---|
| 1765 | xWriteFlag( 0 ); |
---|
| 1766 | } |
---|
| 1767 | return; |
---|
| 1768 | } |
---|
| 1769 | |
---|
| 1770 | Void TEncCavlc::xWriteExGolombLevel( UInt uiSymbol ) |
---|
| 1771 | { |
---|
| 1772 | if( uiSymbol ) |
---|
| 1773 | { |
---|
| 1774 | xWriteFlag( 1 ); |
---|
| 1775 | UInt uiCount = 0; |
---|
| 1776 | Bool bNoExGo = (uiSymbol < 13); |
---|
[56] | 1777 | |
---|
[2] | 1778 | while( --uiSymbol && ++uiCount < 13 ) |
---|
| 1779 | { |
---|
| 1780 | xWriteFlag( 1 ); |
---|
| 1781 | } |
---|
| 1782 | if( bNoExGo ) |
---|
| 1783 | { |
---|
| 1784 | xWriteFlag( 0 ); |
---|
| 1785 | } |
---|
| 1786 | else |
---|
| 1787 | { |
---|
| 1788 | xWriteEpExGolomb( uiSymbol, 0 ); |
---|
| 1789 | } |
---|
| 1790 | } |
---|
| 1791 | else |
---|
| 1792 | { |
---|
| 1793 | xWriteFlag( 0 ); |
---|
| 1794 | } |
---|
| 1795 | return; |
---|
| 1796 | } |
---|
| 1797 | |
---|
| 1798 | Void TEncCavlc::xWriteEpExGolomb( UInt uiSymbol, UInt uiCount ) |
---|
| 1799 | { |
---|
| 1800 | while( uiSymbol >= (UInt)(1<<uiCount) ) |
---|
| 1801 | { |
---|
| 1802 | xWriteFlag( 1 ); |
---|
| 1803 | uiSymbol -= 1<<uiCount; |
---|
| 1804 | uiCount ++; |
---|
| 1805 | } |
---|
| 1806 | xWriteFlag( 0 ); |
---|
| 1807 | while( uiCount-- ) |
---|
| 1808 | { |
---|
| 1809 | xWriteFlag( (uiSymbol>>uiCount) & 1 ); |
---|
| 1810 | } |
---|
| 1811 | return; |
---|
| 1812 | } |
---|
| 1813 | |
---|
[56] | 1814 | /** code explicit wp tables |
---|
| 1815 | * \param TComSlice* pcSlice |
---|
| 1816 | * \returns Void |
---|
[2] | 1817 | */ |
---|
[56] | 1818 | Void TEncCavlc::xCodePredWeightTable( TComSlice* pcSlice ) |
---|
[2] | 1819 | { |
---|
[56] | 1820 | wpScalingParam *wp; |
---|
| 1821 | Bool bChroma = true; // color always present in HEVC ? |
---|
| 1822 | Int iNbRef = (pcSlice->getSliceType() == B_SLICE ) ? (2) : (1); |
---|
| 1823 | Bool bDenomCoded = false; |
---|
[2] | 1824 | |
---|
[56] | 1825 | UInt uiMode = 0; |
---|
| 1826 | if ( (pcSlice->getSliceType()==P_SLICE && pcSlice->getPPS()->getUseWP()) || (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPredIdc()==1 && pcSlice->getRefPicListCombinationFlag()==0 ) ) |
---|
| 1827 | uiMode = 1; // explicit |
---|
| 1828 | else if ( pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPredIdc()==2 ) |
---|
| 1829 | uiMode = 2; // implicit (does not use this mode in this syntax) |
---|
| 1830 | if (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPredIdc()==1 && pcSlice->getRefPicListCombinationFlag()) |
---|
| 1831 | uiMode = 3; // combined explicit |
---|
| 1832 | if(uiMode == 1) |
---|
[2] | 1833 | { |
---|
[56] | 1834 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
[2] | 1835 | { |
---|
[56] | 1836 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
| 1837 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
[2] | 1838 | { |
---|
[56] | 1839 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 1840 | if ( !bDenomCoded ) |
---|
[2] | 1841 | { |
---|
[56] | 1842 | Int iDeltaDenom; |
---|
| 1843 | WRITE_UVLC( wp[0].uiLog2WeightDenom, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
[2] | 1844 | |
---|
[56] | 1845 | if( bChroma ) |
---|
[2] | 1846 | { |
---|
[56] | 1847 | iDeltaDenom = (wp[1].uiLog2WeightDenom - wp[0].uiLog2WeightDenom); |
---|
| 1848 | WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
[2] | 1849 | } |
---|
[56] | 1850 | bDenomCoded = true; |
---|
| 1851 | } |
---|
[2] | 1852 | |
---|
[56] | 1853 | WRITE_FLAG( wp[0].bPresentFlag, "luma_weight_lX_flag" ); // u(1): luma_weight_lX_flag |
---|
[2] | 1854 | |
---|
[56] | 1855 | if ( wp[0].bPresentFlag ) |
---|
| 1856 | { |
---|
| 1857 | Int iDeltaWeight = (wp[0].iWeight - (1<<wp[0].uiLog2WeightDenom)); |
---|
| 1858 | WRITE_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_lX |
---|
| 1859 | WRITE_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_lX |
---|
| 1860 | } |
---|
[2] | 1861 | |
---|
[56] | 1862 | if ( bChroma ) |
---|
| 1863 | { |
---|
| 1864 | WRITE_FLAG( wp[1].bPresentFlag, "chroma_weight_lX_flag" ); // u(1): chroma_weight_lX_flag |
---|
[2] | 1865 | |
---|
[56] | 1866 | if ( wp[1].bPresentFlag ) |
---|
[2] | 1867 | { |
---|
[56] | 1868 | for ( Int j=1 ; j<3 ; j++ ) |
---|
[2] | 1869 | { |
---|
[56] | 1870 | Int iDeltaWeight = (wp[j].iWeight - (1<<wp[1].uiLog2WeightDenom)); |
---|
| 1871 | WRITE_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): delta_chroma_weight_lX |
---|
| 1872 | |
---|
| 1873 | Int iDeltaChroma = (wp[j].iOffset + ( ( (g_uiIBDI_MAX>>1)*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) - (g_uiIBDI_MAX>>1)); |
---|
| 1874 | WRITE_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_lX |
---|
[2] | 1875 | } |
---|
| 1876 | } |
---|
| 1877 | } |
---|
| 1878 | } |
---|
| 1879 | } |
---|
| 1880 | } |
---|
[56] | 1881 | else if (uiMode == 3) |
---|
[2] | 1882 | { |
---|
[56] | 1883 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(REF_PIC_LIST_C) ; iRefIdx++ ) |
---|
| 1884 | { |
---|
| 1885 | RefPicList eRefPicList = (RefPicList)pcSlice->getListIdFromIdxOfLC(iRefIdx); |
---|
| 1886 | Int iCombRefIdx = pcSlice->getRefIdxFromIdxOfLC(iRefIdx); |
---|
[2] | 1887 | |
---|
[56] | 1888 | pcSlice->getWpScaling(eRefPicList, iCombRefIdx, wp); |
---|
| 1889 | if ( !bDenomCoded ) |
---|
[2] | 1890 | { |
---|
[56] | 1891 | Int iDeltaDenom; |
---|
| 1892 | WRITE_UVLC( wp[0].uiLog2WeightDenom, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
| 1893 | |
---|
| 1894 | if( bChroma ) |
---|
| 1895 | { |
---|
| 1896 | iDeltaDenom = (wp[1].uiLog2WeightDenom - wp[0].uiLog2WeightDenom); |
---|
| 1897 | WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
| 1898 | } |
---|
| 1899 | bDenomCoded = true; |
---|
[2] | 1900 | } |
---|
| 1901 | |
---|
[56] | 1902 | WRITE_FLAG( wp[0].bPresentFlag, "luma_weight_lc_flag" ); // u(1): luma_weight_lc_flag |
---|
[2] | 1903 | |
---|
[56] | 1904 | if ( wp[0].bPresentFlag ) |
---|
| 1905 | { |
---|
| 1906 | Int iDeltaWeight = (wp[0].iWeight - (1<<wp[0].uiLog2WeightDenom)); |
---|
| 1907 | WRITE_SVLC( iDeltaWeight, "delta_luma_weight_lc" ); // se(v): delta_luma_weight_lc |
---|
| 1908 | WRITE_SVLC( wp[0].iOffset, "luma_offset_lc" ); // se(v): luma_offset_lc |
---|
| 1909 | } |
---|
| 1910 | if ( bChroma ) |
---|
| 1911 | { |
---|
| 1912 | WRITE_FLAG( wp[1].bPresentFlag, "chroma_weight_lc_flag" ); // u(1): luma_weight_lc_flag |
---|
[2] | 1913 | |
---|
[56] | 1914 | if ( wp[1].bPresentFlag ) |
---|
| 1915 | { |
---|
| 1916 | for ( Int j=1 ; j<3 ; j++ ) |
---|
| 1917 | { |
---|
| 1918 | Int iDeltaWeight = (wp[j].iWeight - (1<<wp[1].uiLog2WeightDenom)); |
---|
| 1919 | WRITE_SVLC( iDeltaWeight, "delta_chroma_weight_lc" ); // se(v): delta_chroma_weight_lc |
---|
[2] | 1920 | |
---|
[56] | 1921 | Int iDeltaChroma = (wp[j].iOffset + ( ( (g_uiIBDI_MAX>>1)*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) - (g_uiIBDI_MAX>>1)); |
---|
| 1922 | WRITE_SVLC( iDeltaChroma, "delta_chroma_offset_lc" ); // se(v): delta_chroma_offset_lc |
---|
| 1923 | } |
---|
| 1924 | } |
---|
| 1925 | } |
---|
[2] | 1926 | } |
---|
| 1927 | } |
---|
[56] | 1928 | } |
---|
[2] | 1929 | |
---|
[56] | 1930 | /** code quantization matrix |
---|
| 1931 | * \param scalingList quantization matrix information |
---|
| 1932 | */ |
---|
| 1933 | Void TEncCavlc::codeScalingList( TComScalingList* scalingList ) |
---|
| 1934 | { |
---|
| 1935 | UInt listId,sizeId; |
---|
| 1936 | Bool scalingListPredModeFlag; |
---|
[2] | 1937 | |
---|
[56] | 1938 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 1939 | Int startBit; |
---|
| 1940 | Int startTotalBit; |
---|
| 1941 | startBit = m_pcBitIf->getNumberOfWrittenBits(); |
---|
| 1942 | startTotalBit = m_pcBitIf->getNumberOfWrittenBits(); |
---|
[2] | 1943 | #endif |
---|
| 1944 | |
---|
[56] | 1945 | WRITE_FLAG( scalingList->getScalingListPresentFlag (), "scaling_list_present_flag" ); |
---|
| 1946 | |
---|
| 1947 | if(scalingList->getScalingListPresentFlag () == false) |
---|
[2] | 1948 | { |
---|
[56] | 1949 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 1950 | printf("Header Bit %d\n",m_pcBitIf->getNumberOfWrittenBits()-startBit); |
---|
[2] | 1951 | #endif |
---|
[56] | 1952 | //for each size |
---|
| 1953 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
[2] | 1954 | { |
---|
[56] | 1955 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
[2] | 1956 | { |
---|
[56] | 1957 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 1958 | startBit = m_pcBitIf->getNumberOfWrittenBits(); |
---|
[2] | 1959 | #endif |
---|
[56] | 1960 | scalingListPredModeFlag = scalingList->checkPredMode( sizeId, listId ); |
---|
| 1961 | WRITE_FLAG( scalingListPredModeFlag, "scaling_list_pred_mode_flag" ); |
---|
| 1962 | if(!scalingListPredModeFlag)// Copy Mode |
---|
[2] | 1963 | { |
---|
[56] | 1964 | WRITE_UVLC( (Int)listId - (Int)scalingList->getRefMatrixId (sizeId,listId) - 1, "scaling_list_pred_matrix_id_delta"); |
---|
[2] | 1965 | } |
---|
[56] | 1966 | else// DPCM Mode |
---|
[2] | 1967 | { |
---|
[56] | 1968 | xCodeScalingList(scalingList, sizeId, listId); |
---|
[2] | 1969 | } |
---|
[56] | 1970 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 1971 | printf("Matrix [%d][%d] Bit %d\n",sizeId,listId,m_pcBitIf->getNumberOfWrittenBits() - startBit); |
---|
[2] | 1972 | #endif |
---|
| 1973 | } |
---|
| 1974 | } |
---|
| 1975 | } |
---|
[56] | 1976 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 1977 | else |
---|
[2] | 1978 | { |
---|
[56] | 1979 | printf("Header Bit %d\n",m_pcBitIf->getNumberOfWrittenBits()-startTotalBit); |
---|
[2] | 1980 | } |
---|
[56] | 1981 | printf("Total Bit %d\n",m_pcBitIf->getNumberOfWrittenBits()-startTotalBit); |
---|
| 1982 | #endif |
---|
[2] | 1983 | return; |
---|
| 1984 | } |
---|
[56] | 1985 | /** code DPCM |
---|
| 1986 | * \param scalingList quantization matrix information |
---|
| 1987 | * \param sizeIdc size index |
---|
| 1988 | * \param listIdc list index |
---|
| 1989 | */ |
---|
| 1990 | Void TEncCavlc::xCodeScalingList(TComScalingList* scalingList, UInt sizeId, UInt listId) |
---|
[2] | 1991 | { |
---|
[56] | 1992 | #if SCALING_LIST |
---|
| 1993 | Int coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
| 1994 | UInt* scan = g_auiFrameScanXY [ (sizeId == 0)? 1 : 2]; |
---|
[2] | 1995 | #else |
---|
[56] | 1996 | Int coefNum = (Int)g_scalingListSize[sizeId]; |
---|
| 1997 | UInt* scan = g_auiFrameScanXY [ sizeId + 1]; |
---|
[2] | 1998 | #endif |
---|
[56] | 1999 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
| 2000 | Int data; |
---|
| 2001 | Int *src = scalingList->getScalingListAddress(sizeId, listId); |
---|
| 2002 | #if SCALING_LIST |
---|
| 2003 | if(sizeId > SCALING_LIST_8x8 && scalingList->getUseDefaultScalingMatrixFlag(sizeId,listId)) |
---|
[2] | 2004 | { |
---|
[56] | 2005 | WRITE_SVLC( -8, "scaling_list_dc_coef_minus8"); |
---|
[2] | 2006 | } |
---|
[56] | 2007 | else if(sizeId < SCALING_LIST_16x16 && scalingList->getUseDefaultScalingMatrixFlag(sizeId,listId)) |
---|
[2] | 2008 | { |
---|
[56] | 2009 | WRITE_SVLC( -8, "scaling_list_delta_coef"); |
---|
[2] | 2010 | } |
---|
[56] | 2011 | else |
---|
[2] | 2012 | { |
---|
[56] | 2013 | if( sizeId > SCALING_LIST_8x8 ) |
---|
[2] | 2014 | { |
---|
[56] | 2015 | WRITE_SVLC( scalingList->getScalingListDC(sizeId,listId) - 8, "scaling_list_dc_coef_minus8"); |
---|
[2] | 2016 | } |
---|
[56] | 2017 | for(Int i=0;i<coefNum;i++) |
---|
[2] | 2018 | { |
---|
[56] | 2019 | data = src[scan[i]] - nextCoef; |
---|
| 2020 | nextCoef = src[scan[i]]; |
---|
| 2021 | if(data > 127) |
---|
[2] | 2022 | { |
---|
[56] | 2023 | data = data - 256; |
---|
[2] | 2024 | } |
---|
[56] | 2025 | if(data < -128) |
---|
[2] | 2026 | { |
---|
[56] | 2027 | data = data + 256; |
---|
[2] | 2028 | } |
---|
| 2029 | |
---|
[56] | 2030 | WRITE_SVLC( data, "scaling_list_delta_coef"); |
---|
[2] | 2031 | } |
---|
| 2032 | } |
---|
[56] | 2033 | #else |
---|
| 2034 | for(Int i=0;i<coefNum;i++) |
---|
[2] | 2035 | { |
---|
[56] | 2036 | data = src[scan[i]] - nextCoef; |
---|
| 2037 | nextCoef = src[scan[i]]; |
---|
| 2038 | if(data > 127) |
---|
[2] | 2039 | { |
---|
[56] | 2040 | data = data - 256; |
---|
[2] | 2041 | } |
---|
[56] | 2042 | if(data < -128) |
---|
[2] | 2043 | { |
---|
[56] | 2044 | data = data + 256; |
---|
[2] | 2045 | } |
---|
[56] | 2046 | |
---|
| 2047 | WRITE_SVLC( data, "delta_coef"); |
---|
[2] | 2048 | } |
---|
[56] | 2049 | #endif |
---|
[2] | 2050 | } |
---|
[56] | 2051 | Bool TComScalingList::checkPredMode(UInt sizeId, UInt listId) |
---|
| 2052 | { |
---|
| 2053 | for(Int predListIdx = (Int)listId -1 ; predListIdx >= 0; predListIdx--) |
---|
| 2054 | { |
---|
| 2055 | #if SCALING_LIST |
---|
| 2056 | if( !memcmp(getScalingListAddress(sizeId,listId),getScalingListAddress(sizeId, predListIdx),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
| 2057 | && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == getScalingListDC(sizeId,predListIdx)))) // check DC value |
---|
| 2058 | #else |
---|
| 2059 | if( !memcmp(getScalingListAddress(sizeId,listId),getScalingListAddress(sizeId, predListIdx),sizeof(Int)*(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
[2] | 2060 | #endif |
---|
[56] | 2061 | { |
---|
| 2062 | setRefMatrixId(sizeId, listId, predListIdx); |
---|
| 2063 | return false; |
---|
[2] | 2064 | } |
---|
| 2065 | } |
---|
[56] | 2066 | return true; |
---|
[2] | 2067 | } |
---|
[56] | 2068 | //! \} |
---|