[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 | { |
---|
| 380 | WRITE_CODE( pcVPS->getMaxTLayers() - 1, 3, "max_temporal_layers_minus1" ); |
---|
| 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" ); |
---|
| 751 | if(address>0) |
---|
[2] | 752 | { |
---|
[56] | 753 | WRITE_CODE( address, reqBitsOuter+reqBitsInner, "slice_address" ); |
---|
[2] | 754 | } |
---|
| 755 | |
---|
[56] | 756 | WRITE_UVLC( pcSlice->getSliceType(), "slice_type" ); |
---|
| 757 | Bool bEntropySlice = (!pcSlice->isNextSlice()); |
---|
| 758 | WRITE_FLAG( bEntropySlice ? 1 : 0, "lightweight_slice_flag" ); |
---|
| 759 | |
---|
| 760 | if (!bEntropySlice) |
---|
[2] | 761 | { |
---|
[56] | 762 | WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "pic_parameter_set_id" ); |
---|
| 763 | #if H0388 |
---|
| 764 | if( pcSlice->getPPS()->getOutputFlagPresentFlag() ) |
---|
[2] | 765 | { |
---|
[56] | 766 | WRITE_FLAG( pcSlice->getPicOutputFlag() ? 1 : 0, "pic_output_flag" ); |
---|
[2] | 767 | } |
---|
| 768 | #endif |
---|
[56] | 769 | if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_IDR) |
---|
[2] | 770 | { |
---|
[56] | 771 | WRITE_UVLC( 0, "idr_pic_id" ); |
---|
| 772 | WRITE_FLAG( 0, "no_output_of_prior_pics_flag" ); |
---|
[2] | 773 | } |
---|
| 774 | else |
---|
| 775 | { |
---|
[56] | 776 | WRITE_CODE( (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC()))%(1<<pcSlice->getSPS()->getBitsForPOC()), pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb"); |
---|
[77] | 777 | #if HHI_FIX |
---|
| 778 | if( pcSlice->getPOC() == 0 && pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDV ) |
---|
| 779 | { |
---|
| 780 | TComReferencePictureSet* rps = pcSlice->getRPS(); |
---|
| 781 | if(pcSlice->getRPSidx() < 0) |
---|
| 782 | { |
---|
| 783 | WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag"); |
---|
| 784 | #if RPS_IN_SPS |
---|
| 785 | codeShortTermRefPicSet(pcSlice->getSPS(), rps); |
---|
| 786 | #else |
---|
| 787 | codeShortTermRefPicSet(pcSlice->getPPS(), rps); |
---|
| 788 | #endif |
---|
| 789 | } |
---|
| 790 | else |
---|
| 791 | { |
---|
| 792 | WRITE_FLAG( 1, "short_term_ref_pic_set_sps_flag"); |
---|
| 793 | WRITE_UVLC( pcSlice->getRPSidx(), "short_term_ref_pic_set_idx" ); |
---|
| 794 | } |
---|
| 795 | #if RPS_IN_SPS |
---|
| 796 | if(pcSlice->getSPS()->getLongTermRefsPresent()) |
---|
| 797 | #else |
---|
| 798 | if(pcSlice->getPPS()->getLongTermRefsPresent()) |
---|
| 799 | #endif |
---|
| 800 | { |
---|
| 801 | WRITE_UVLC( rps->getNumberOfLongtermPictures(), "num_long_term_pics"); |
---|
| 802 | Int maxPocLsb = 1<<pcSlice->getSPS()->getBitsForPOC(); |
---|
| 803 | Int prev = 0; |
---|
| 804 | #if LTRP_MULT |
---|
| 805 | Int prevDeltaPocLt=0; |
---|
| 806 | Int currDeltaPocLt=0; |
---|
| 807 | #endif |
---|
| 808 | for(Int i=rps->getNumberOfPictures()-1 ; i > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; i--) |
---|
| 809 | { |
---|
| 810 | WRITE_UVLC((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb, "delta_poc_lsb_lt"); |
---|
| 811 | |
---|
| 812 | #if LTRP_MULT |
---|
| 813 | currDeltaPocLt=((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb)+prevDeltaPocLt; |
---|
[2] | 814 | |
---|
[77] | 815 | Int deltaMsbCycle=0; |
---|
| 816 | if( (i==(rps->getNumberOfPictures()-1)) ) |
---|
| 817 | { |
---|
| 818 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 819 | } |
---|
| 820 | else if( prevDeltaPocLt!=currDeltaPocLt ) |
---|
| 821 | { |
---|
| 822 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 823 | if( ((prevDeltaPocLt==maxPocLsb-1) && (currDeltaPocLt==maxPocLsb+1)) || ((prevDeltaPocLt==maxPocLsb-2) && (currDeltaPocLt==maxPocLsb))) |
---|
| 824 | { |
---|
| 825 | deltaMsbCycle=deltaMsbCycle-1; |
---|
| 826 | } |
---|
| 827 | } |
---|
| 828 | else |
---|
| 829 | { |
---|
| 830 | deltaMsbCycle=((rps->getDeltaPOC(i+1)-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 831 | } |
---|
| 832 | |
---|
| 833 | if(deltaMsbCycle>=0) |
---|
| 834 | { |
---|
| 835 | WRITE_FLAG( 1, "delta_poc_msb_present_flag"); |
---|
| 836 | WRITE_UVLC(deltaMsbCycle, "delta_poc_msb_cycle_lt_minus1"); |
---|
| 837 | } |
---|
| 838 | else |
---|
| 839 | { |
---|
| 840 | WRITE_FLAG( 0, "delta_poc_msb_present_flag"); |
---|
| 841 | } |
---|
| 842 | prevDeltaPocLt=currDeltaPocLt; |
---|
| 843 | #endif |
---|
| 844 | prev = rps->getDeltaPOC(i); |
---|
| 845 | WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag"); |
---|
| 846 | } |
---|
| 847 | } |
---|
| 848 | } |
---|
| 849 | if( pcSlice->getPOC() != 0 ) |
---|
| 850 | #else |
---|
[56] | 851 | if( pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDV ) |
---|
[77] | 852 | #endif |
---|
[2] | 853 | { |
---|
[56] | 854 | TComReferencePictureSet* rps = pcSlice->getRPS(); |
---|
| 855 | if(pcSlice->getRPSidx() < 0) |
---|
| 856 | { |
---|
| 857 | WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag"); |
---|
| 858 | #if RPS_IN_SPS |
---|
| 859 | codeShortTermRefPicSet(pcSlice->getSPS(), rps); |
---|
| 860 | #else |
---|
| 861 | codeShortTermRefPicSet(pcSlice->getPPS(), rps); |
---|
[2] | 862 | #endif |
---|
[56] | 863 | } |
---|
| 864 | else |
---|
[2] | 865 | { |
---|
[56] | 866 | WRITE_FLAG( 1, "short_term_ref_pic_set_sps_flag"); |
---|
| 867 | WRITE_UVLC( pcSlice->getRPSidx(), "short_term_ref_pic_set_idx" ); |
---|
[2] | 868 | } |
---|
[56] | 869 | #if RPS_IN_SPS |
---|
| 870 | if(pcSlice->getSPS()->getLongTermRefsPresent()) |
---|
| 871 | #else |
---|
| 872 | if(pcSlice->getPPS()->getLongTermRefsPresent()) |
---|
[2] | 873 | #endif |
---|
| 874 | { |
---|
[56] | 875 | WRITE_UVLC( rps->getNumberOfLongtermPictures(), "num_long_term_pics"); |
---|
| 876 | Int maxPocLsb = 1<<pcSlice->getSPS()->getBitsForPOC(); |
---|
| 877 | Int prev = 0; |
---|
| 878 | #if LTRP_MULT |
---|
| 879 | Int prevDeltaPocLt=0; |
---|
| 880 | Int currDeltaPocLt=0; |
---|
| 881 | #endif |
---|
| 882 | for(Int i=rps->getNumberOfPictures()-1 ; i > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; i--) |
---|
| 883 | { |
---|
| 884 | WRITE_UVLC((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb, "delta_poc_lsb_lt"); |
---|
| 885 | |
---|
| 886 | #if LTRP_MULT |
---|
| 887 | currDeltaPocLt=((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb)+prevDeltaPocLt; |
---|
| 888 | |
---|
| 889 | Int deltaMsbCycle=0; |
---|
| 890 | if( (i==(rps->getNumberOfPictures()-1)) ) |
---|
| 891 | { |
---|
| 892 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 893 | } |
---|
| 894 | else if( prevDeltaPocLt!=currDeltaPocLt ) |
---|
| 895 | { |
---|
| 896 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 897 | if( ((prevDeltaPocLt==maxPocLsb-1) && (currDeltaPocLt==maxPocLsb+1)) || ((prevDeltaPocLt==maxPocLsb-2) && (currDeltaPocLt==maxPocLsb))) |
---|
| 898 | { |
---|
| 899 | deltaMsbCycle=deltaMsbCycle-1; |
---|
| 900 | } |
---|
| 901 | } |
---|
| 902 | else |
---|
| 903 | { |
---|
| 904 | deltaMsbCycle=((rps->getDeltaPOC(i+1)-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 905 | } |
---|
| 906 | |
---|
| 907 | if(deltaMsbCycle>=0) |
---|
| 908 | { |
---|
| 909 | WRITE_FLAG( 1, "delta_poc_msb_present_flag"); |
---|
| 910 | WRITE_UVLC(deltaMsbCycle, "delta_poc_msb_cycle_lt_minus1"); |
---|
| 911 | } |
---|
| 912 | else |
---|
| 913 | { |
---|
| 914 | WRITE_FLAG( 0, "delta_poc_msb_present_flag"); |
---|
| 915 | } |
---|
| 916 | prevDeltaPocLt=currDeltaPocLt; |
---|
| 917 | #endif |
---|
| 918 | prev = rps->getDeltaPOC(i); |
---|
| 919 | WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag"); |
---|
| 920 | } |
---|
[2] | 921 | } |
---|
| 922 | } |
---|
| 923 | } |
---|
[56] | 924 | |
---|
| 925 | if(pcSlice->getSPS()->getUseSAO() || pcSlice->getSPS()->getUseALF()|| pcSlice->getSPS()->getScalingListFlag() || pcSlice->getSPS()->getUseDF()) |
---|
[2] | 926 | { |
---|
[56] | 927 | if (pcSlice->getSPS()->getUseALF()) |
---|
[2] | 928 | { |
---|
[56] | 929 | #if !LCU_SYNTAX_ALF |
---|
| 930 | if (pcSlice->getAlfEnabledFlag()) |
---|
| 931 | { |
---|
| 932 | assert (pcSlice->getAPS()->getAlfEnabled()); |
---|
| 933 | } |
---|
[2] | 934 | #endif |
---|
[56] | 935 | WRITE_FLAG( pcSlice->getAlfEnabledFlag(), "ALF on/off flag in slice header" ); |
---|
[2] | 936 | } |
---|
[56] | 937 | if (pcSlice->getSPS()->getUseSAO()) |
---|
[2] | 938 | { |
---|
[56] | 939 | #if SAO_UNIT_INTERLEAVING |
---|
| 940 | WRITE_FLAG( pcSlice->getSaoInterleavingFlag(), "SAO interleaving flag" ); |
---|
[2] | 941 | #endif |
---|
[56] | 942 | assert (pcSlice->getSaoEnabledFlag() == pcSlice->getAPS()->getSaoEnabled()); |
---|
| 943 | WRITE_FLAG( pcSlice->getSaoEnabledFlag(), "SAO on/off flag in slice header" ); |
---|
| 944 | #if SAO_UNIT_INTERLEAVING |
---|
| 945 | if (pcSlice->getSaoInterleavingFlag()&&pcSlice->getSaoEnabledFlag() ) |
---|
| 946 | { |
---|
| 947 | WRITE_FLAG( pcSlice->getAPS()->getSaoParam()->bSaoFlag[1], "SAO on/off flag for Cb in slice header" ); |
---|
| 948 | WRITE_FLAG( pcSlice->getAPS()->getSaoParam()->bSaoFlag[2], "SAO on/off flag for Cr in slice header" ); |
---|
| 949 | } |
---|
| 950 | #endif |
---|
[2] | 951 | } |
---|
[56] | 952 | WRITE_UVLC( pcSlice->getAPS()->getAPSID(), "aps_id"); |
---|
[2] | 953 | } |
---|
[56] | 954 | |
---|
| 955 | // we always set num_ref_idx_active_override_flag equal to one. this might be done in a more intelligent way |
---|
| 956 | if (!pcSlice->isIntra()) |
---|
| 957 | { |
---|
| 958 | WRITE_FLAG( 1 , "num_ref_idx_active_override_flag"); |
---|
| 959 | WRITE_CODE( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - 1, 3, "num_ref_idx_l0_active_minus1" ); |
---|
| 960 | } |
---|
[2] | 961 | else |
---|
| 962 | { |
---|
[56] | 963 | pcSlice->setNumRefIdx(REF_PIC_LIST_0, 0); |
---|
[2] | 964 | } |
---|
[56] | 965 | if (pcSlice->isInterB()) |
---|
[2] | 966 | { |
---|
[56] | 967 | WRITE_CODE( pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - 1, 3, "num_ref_idx_l1_active_minus1" ); |
---|
[2] | 968 | } |
---|
[56] | 969 | else |
---|
[2] | 970 | { |
---|
[56] | 971 | pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
[2] | 972 | } |
---|
[56] | 973 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
| 974 | if( pcSlice->getSPS()->getListsModificationPresentFlag() ) |
---|
| 975 | { |
---|
[2] | 976 | #endif |
---|
[56] | 977 | TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); |
---|
| 978 | #if H0137_0138_LIST_MODIFICATION |
---|
| 979 | if( !pcSlice->isIntra() ) |
---|
[2] | 980 | { |
---|
[56] | 981 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0() ? 1 : 0, "ref_pic_list_modification_flag_l0" ); |
---|
| 982 | if (pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0()) |
---|
[2] | 983 | { |
---|
[56] | 984 | Int NumPocTotalCurr = pcSlice->getNumPocTotalCurrMvc(); |
---|
| 985 | if (NumPocTotalCurr > 1) |
---|
[2] | 986 | { |
---|
[56] | 987 | Int length = 1; |
---|
| 988 | NumPocTotalCurr --; |
---|
| 989 | while ( NumPocTotalCurr >>= 1) |
---|
[2] | 990 | { |
---|
[56] | 991 | length ++; |
---|
[2] | 992 | } |
---|
[56] | 993 | for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_0 ); i++) |
---|
[2] | 994 | { |
---|
[56] | 995 | WRITE_CODE( refPicListModification->getRefPicSetIdxL0(i), length, "list_entry_l0"); |
---|
[2] | 996 | } |
---|
| 997 | } |
---|
| 998 | } |
---|
[56] | 999 | } |
---|
| 1000 | if(pcSlice->isInterB()) |
---|
| 1001 | { |
---|
| 1002 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1() ? 1 : 0, "ref_pic_list_modification_flag_l1" ); |
---|
| 1003 | if (pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1()) |
---|
[2] | 1004 | { |
---|
[56] | 1005 | Int NumPocTotalCurr = pcSlice->getNumPocTotalCurrMvc(); |
---|
| 1006 | if ( NumPocTotalCurr > 1 ) |
---|
[2] | 1007 | { |
---|
[56] | 1008 | Int length = 1; |
---|
| 1009 | NumPocTotalCurr --; |
---|
| 1010 | while ( NumPocTotalCurr >>= 1) |
---|
[2] | 1011 | { |
---|
[56] | 1012 | length ++; |
---|
[2] | 1013 | } |
---|
[56] | 1014 | for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_1 ); i++) |
---|
[2] | 1015 | { |
---|
[56] | 1016 | WRITE_CODE( refPicListModification->getRefPicSetIdxL1(i), length, "list_entry_l1"); |
---|
[2] | 1017 | } |
---|
| 1018 | } |
---|
| 1019 | } |
---|
| 1020 | } |
---|
| 1021 | #else |
---|
[56] | 1022 | if(!pcSlice->isIntra()) |
---|
[2] | 1023 | { |
---|
[56] | 1024 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0() ? 1 : 0, "ref_pic_list_modification_flag" ); |
---|
| 1025 | for(Int i = 0; i < refPicListModification->getNumberOfRefPicListModificationsL0(); i++) |
---|
[2] | 1026 | { |
---|
[56] | 1027 | WRITE_UVLC( refPicListModification->getListIdcL0(i), "ref_pic_list_modification_idc"); |
---|
| 1028 | WRITE_UVLC( refPicListModification->getRefPicSetIdxL0(i), "ref_pic_set_idx"); |
---|
[2] | 1029 | } |
---|
[56] | 1030 | if(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0()) |
---|
| 1031 | WRITE_UVLC( 3, "ref_pic_list_modification_idc"); |
---|
| 1032 | } |
---|
| 1033 | if(pcSlice->isInterB()) |
---|
| 1034 | { |
---|
| 1035 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1() ? 1 : 0, "ref_pic_list_modification_flag" ); |
---|
| 1036 | for(Int i = 0; i < refPicListModification->getNumberOfRefPicListModificationsL1(); i++) |
---|
[2] | 1037 | { |
---|
[56] | 1038 | WRITE_UVLC( refPicListModification->getListIdcL1(i), "ref_pic_list_modification_idc"); |
---|
| 1039 | WRITE_UVLC( refPicListModification->getRefPicSetIdxL1(i), "ref_pic_set_idx"); |
---|
[2] | 1040 | } |
---|
[56] | 1041 | if(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1()) |
---|
| 1042 | WRITE_UVLC( 3, "ref_pic_list_modification_idc"); |
---|
[2] | 1043 | } |
---|
[56] | 1044 | #endif |
---|
| 1045 | } |
---|
| 1046 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
| 1047 | } |
---|
| 1048 | #endif |
---|
| 1049 | // ref_pic_list_combination( ) |
---|
| 1050 | // maybe move to own function? |
---|
| 1051 | if (pcSlice->isInterB()) |
---|
| 1052 | { |
---|
| 1053 | WRITE_FLAG(pcSlice->getRefPicListCombinationFlag() ? 1 : 0, "ref_pic_list_combination_flag" ); |
---|
| 1054 | if(pcSlice->getRefPicListCombinationFlag()) |
---|
| 1055 | { |
---|
| 1056 | WRITE_UVLC( pcSlice->getNumRefIdx(REF_PIC_LIST_C) - 1, "num_ref_idx lc_active_minus1"); |
---|
| 1057 | |
---|
| 1058 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
| 1059 | if( pcSlice->getSPS()->getListsModificationPresentFlag() ) |
---|
[2] | 1060 | { |
---|
[56] | 1061 | #endif |
---|
| 1062 | WRITE_FLAG( pcSlice->getRefPicListModificationFlagLC() ? 1 : 0, "ref_pic_list_modification_flag_lc" ); |
---|
| 1063 | if(pcSlice->getRefPicListModificationFlagLC()) |
---|
[2] | 1064 | { |
---|
[56] | 1065 | for (UInt i=0;i<pcSlice->getNumRefIdx(REF_PIC_LIST_C);i++) |
---|
| 1066 | { |
---|
| 1067 | WRITE_FLAG( pcSlice->getListIdFromIdxOfLC(i), "pic_from_list_0_flag" ); |
---|
| 1068 | #if H0137_0138_LIST_MODIFICATION |
---|
| 1069 | 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 ) ) |
---|
| 1070 | { |
---|
| 1071 | WRITE_UVLC( pcSlice->getRefIdxFromIdxOfLC(i), "ref_idx_list_curr" ); |
---|
| 1072 | } |
---|
| 1073 | #else |
---|
| 1074 | WRITE_UVLC( pcSlice->getRefIdxFromIdxOfLC(i), "ref_idx_list_curr" ); |
---|
| 1075 | #endif |
---|
| 1076 | } |
---|
[2] | 1077 | } |
---|
[56] | 1078 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
[2] | 1079 | } |
---|
| 1080 | #endif |
---|
| 1081 | } |
---|
| 1082 | } |
---|
[56] | 1083 | |
---|
| 1084 | #if H0111_MVD_L1_ZERO |
---|
| 1085 | if (pcSlice->isInterB()) |
---|
[2] | 1086 | { |
---|
[56] | 1087 | WRITE_FLAG( pcSlice->getMvdL1ZeroFlag() ? 1 : 0, "mvd_l1_zero_flag"); |
---|
[2] | 1088 | } |
---|
| 1089 | #endif |
---|
| 1090 | |
---|
[56] | 1091 | if(pcSlice->getPPS()->getEntropyCodingMode() && !pcSlice->isIntra()) |
---|
[2] | 1092 | { |
---|
[56] | 1093 | #if CABAC_INIT_FLAG |
---|
| 1094 | if (!pcSlice->isIntra() && pcSlice->getPPS()->getCabacInitPresentFlag()) |
---|
[2] | 1095 | { |
---|
[56] | 1096 | SliceType sliceType = pcSlice->getSliceType(); |
---|
| 1097 | Int encCABACTableIdx = pcSlice->getPPS()->getEncCABACTableIdx(); |
---|
| 1098 | Bool encCabacInitFlag = (sliceType!=encCABACTableIdx && encCABACTableIdx!=0) ? true : false; |
---|
| 1099 | pcSlice->setCabacInitFlag( encCabacInitFlag ); |
---|
| 1100 | WRITE_FLAG( encCabacInitFlag?1:0, "cabac_init_flag" ); |
---|
[2] | 1101 | } |
---|
| 1102 | #else |
---|
[56] | 1103 | WRITE_UVLC(pcSlice->getCABACinitIDC(), "cabac_init_idc"); |
---|
[2] | 1104 | #endif |
---|
| 1105 | } |
---|
| 1106 | |
---|
[56] | 1107 | // if( !lightweight_slice_flag ) { |
---|
| 1108 | if (!bEntropySlice) |
---|
[2] | 1109 | { |
---|
[56] | 1110 | Int iCode = pcSlice->getSliceQp() - ( pcSlice->getPPS()->getPicInitQPMinus26() + 26 ); |
---|
| 1111 | WRITE_SVLC( iCode, "slice_qp_delta" ); |
---|
| 1112 | #if DBL_CONTROL |
---|
| 1113 | if (pcSlice->getPPS()->getDeblockingFilterControlPresent()) |
---|
[2] | 1114 | { |
---|
[56] | 1115 | if ( pcSlice->getSPS()->getUseDF() ) |
---|
[2] | 1116 | { |
---|
[56] | 1117 | WRITE_FLAG(pcSlice->getInheritDblParamFromAPS(), "inherit_dbl_param_from_APS_flag"); |
---|
[2] | 1118 | } |
---|
[56] | 1119 | #else |
---|
| 1120 | WRITE_FLAG(pcSlice->getInheritDblParamFromAPS(), "inherit_dbl_param_from_APS_flag"); |
---|
| 1121 | #endif |
---|
| 1122 | if (!pcSlice->getInheritDblParamFromAPS()) |
---|
[2] | 1123 | { |
---|
[56] | 1124 | WRITE_FLAG(pcSlice->getLoopFilterDisable(), "loop_filter_disable"); // should be an IDC |
---|
| 1125 | if(!pcSlice->getLoopFilterDisable()) |
---|
| 1126 | { |
---|
| 1127 | WRITE_SVLC (pcSlice->getLoopFilterBetaOffset(), "beta_offset_div2"); |
---|
| 1128 | WRITE_SVLC (pcSlice->getLoopFilterTcOffset(), "tc_offset_div2"); |
---|
| 1129 | } |
---|
[2] | 1130 | } |
---|
[56] | 1131 | #if DBL_CONTROL |
---|
| 1132 | } |
---|
| 1133 | #endif |
---|
| 1134 | if ( pcSlice->getSliceType() == B_SLICE ) |
---|
| 1135 | { |
---|
| 1136 | WRITE_FLAG( pcSlice->getColDir(), "collocated_from_l0_flag" ); |
---|
| 1137 | } |
---|
[2] | 1138 | |
---|
[56] | 1139 | #if COLLOCATED_REF_IDX |
---|
| 1140 | if ( pcSlice->getSliceType() != I_SLICE && |
---|
| 1141 | ((pcSlice->getColDir()==0 && pcSlice->getNumRefIdx(REF_PIC_LIST_0)>1)|| |
---|
| 1142 | (pcSlice->getColDir()==1 && pcSlice->getNumRefIdx(REF_PIC_LIST_1)>1))) |
---|
| 1143 | { |
---|
| 1144 | WRITE_UVLC( pcSlice->getColRefIdx(), "collocated_ref_idx" ); |
---|
[2] | 1145 | } |
---|
[56] | 1146 | #endif |
---|
| 1147 | |
---|
| 1148 | if ( (pcSlice->getPPS()->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pcSlice->getPPS()->getWPBiPredIdc()==1 && pcSlice->getSliceType()==B_SLICE) ) |
---|
[2] | 1149 | { |
---|
[56] | 1150 | xCodePredWeightTable( pcSlice ); |
---|
[2] | 1151 | } |
---|
| 1152 | } |
---|
| 1153 | |
---|
[56] | 1154 | // !!!! sytnax elements not in the WD !!!! |
---|
| 1155 | if (!bEntropySlice) |
---|
[2] | 1156 | { |
---|
[56] | 1157 | if( pcSlice->getSPS()->hasCamParInSliceHeader() ) |
---|
| 1158 | { |
---|
| 1159 | for( UInt uiId = 0; uiId < pcSlice->getSPS()->getViewId(); uiId++ ) |
---|
| 1160 | { |
---|
| 1161 | WRITE_SVLC( pcSlice->getCodedScale ()[ uiId ], "coded_scale" ); |
---|
| 1162 | WRITE_SVLC( pcSlice->getCodedOffset ()[ uiId ], "coded_offset" ); |
---|
| 1163 | WRITE_SVLC( pcSlice->getInvCodedScale ()[ uiId ] + pcSlice->getCodedScale ()[ uiId ], "inverse_coded_scale_plus_coded_scale" ); |
---|
| 1164 | WRITE_SVLC( pcSlice->getInvCodedOffset()[ uiId ] + pcSlice->getCodedOffset()[ uiId ], "inverse_coded_offset_plus_coded_offset" ); |
---|
| 1165 | } |
---|
| 1166 | } |
---|
[2] | 1167 | } |
---|
[56] | 1168 | |
---|
| 1169 | #if ( HHI_MPI || HHI_INTER_VIEW_MOTION_PRED ) |
---|
| 1170 | #if ( HHI_MPI && HHI_INTER_VIEW_MOTION_PRED ) |
---|
| 1171 | const int iExtraMergeCandidates = ( pcSlice->getSPS()->getUseMVI() || pcSlice->getSPS()->getMultiviewMvPredMode() ) ? 1 : 0; |
---|
| 1172 | #elif HHI_MPI |
---|
| 1173 | const int iExtraMergeCandidates = pcSlice->getSPS()->getUseMVI() ? 1 : 0; |
---|
| 1174 | #else |
---|
| 1175 | const int iExtraMergeCandidates = pcSlice->getSPS()->getMultiviewMvPredMode() ? 1 : 0; |
---|
| 1176 | #endif |
---|
| 1177 | assert(pcSlice->getMaxNumMergeCand()<=(MRG_MAX_NUM_CANDS_SIGNALED+iExtraMergeCandidates)); |
---|
| 1178 | assert(MRG_MAX_NUM_CANDS_SIGNALED<=MRG_MAX_NUM_CANDS); |
---|
| 1179 | WRITE_UVLC(MRG_MAX_NUM_CANDS + iExtraMergeCandidates - pcSlice->getMaxNumMergeCand(), "maxNumMergeCand"); |
---|
[2] | 1180 | #else |
---|
[56] | 1181 | assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS_SIGNALED); |
---|
| 1182 | assert(MRG_MAX_NUM_CANDS_SIGNALED<=MRG_MAX_NUM_CANDS); |
---|
| 1183 | WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSlice->getMaxNumMergeCand(), "maxNumMergeCand"); |
---|
[2] | 1184 | #endif |
---|
| 1185 | } |
---|
| 1186 | |
---|
| 1187 | |
---|
[56] | 1188 | Void TEncCavlc::codeTileMarkerFlag(TComSlice* pcSlice) |
---|
[2] | 1189 | { |
---|
[56] | 1190 | Bool bEntropySlice = (!pcSlice->isNextSlice()); |
---|
| 1191 | if (!bEntropySlice) |
---|
| 1192 | { |
---|
| 1193 | xWriteFlag (pcSlice->getTileMarkerFlag() ? 1 : 0 ); |
---|
| 1194 | } |
---|
[2] | 1195 | } |
---|
| 1196 | |
---|
[56] | 1197 | /** |
---|
| 1198 | - write wavefront substreams sizes for the slice header. |
---|
| 1199 | . |
---|
| 1200 | \param pcSlice Where we find the substream size information. |
---|
| 1201 | */ |
---|
| 1202 | #if TILES_WPP_ENTRY_POINT_SIGNALLING |
---|
| 1203 | Void TEncCavlc::codeTilesWPPEntryPoint( TComSlice* pSlice ) |
---|
[2] | 1204 | { |
---|
[56] | 1205 | Int tilesOrEntropyCodingSyncIdc = pSlice->getSPS()->getTilesOrEntropyCodingSyncIdc(); |
---|
[2] | 1206 | |
---|
[56] | 1207 | if ( tilesOrEntropyCodingSyncIdc == 0 ) |
---|
[2] | 1208 | { |
---|
[56] | 1209 | return; |
---|
[2] | 1210 | } |
---|
| 1211 | |
---|
[56] | 1212 | UInt numEntryPointOffsets = 0, offsetLenMinus1 = 0, maxOffset = 0; |
---|
| 1213 | UInt *entryPointOffset = NULL; |
---|
| 1214 | if (tilesOrEntropyCodingSyncIdc == 1) // tiles |
---|
[2] | 1215 | { |
---|
[56] | 1216 | numEntryPointOffsets = pSlice->getTileLocationCount(); |
---|
| 1217 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
| 1218 | for (Int idx=0; idx<pSlice->getTileLocationCount(); idx++) |
---|
[2] | 1219 | { |
---|
[56] | 1220 | if ( idx == 0 ) |
---|
[2] | 1221 | { |
---|
[56] | 1222 | entryPointOffset [ idx ] = pSlice->getTileLocation( 0 ); |
---|
[2] | 1223 | } |
---|
[56] | 1224 | else |
---|
[2] | 1225 | { |
---|
[56] | 1226 | entryPointOffset [ idx ] = pSlice->getTileLocation( idx ) - pSlice->getTileLocation( idx-1 ); |
---|
[2] | 1227 | } |
---|
| 1228 | |
---|
[56] | 1229 | if ( entryPointOffset[ idx ] > maxOffset ) |
---|
| 1230 | { |
---|
| 1231 | maxOffset = entryPointOffset[ idx ]; |
---|
| 1232 | } |
---|
[2] | 1233 | } |
---|
| 1234 | } |
---|
[56] | 1235 | else if (tilesOrEntropyCodingSyncIdc == 2) // wavefront |
---|
[2] | 1236 | { |
---|
[56] | 1237 | Int numZeroSubstreamsAtEndOfSlice = 0; |
---|
| 1238 | UInt* pSubstreamSizes = pSlice->getSubstreamSizes(); |
---|
| 1239 | // Find number of zero substreams at the end of slice |
---|
| 1240 | for (Int idx=pSlice->getPPS()->getNumSubstreams()-2; idx>=0; idx--) |
---|
[2] | 1241 | { |
---|
[56] | 1242 | if ( pSubstreamSizes[ idx ] == 0 ) |
---|
[2] | 1243 | { |
---|
[56] | 1244 | numZeroSubstreamsAtEndOfSlice++; |
---|
[2] | 1245 | } |
---|
[56] | 1246 | else |
---|
[2] | 1247 | { |
---|
[56] | 1248 | break; |
---|
[2] | 1249 | } |
---|
| 1250 | } |
---|
[56] | 1251 | numEntryPointOffsets = pSlice->getPPS()->getNumSubstreams() - 1 - numZeroSubstreamsAtEndOfSlice; |
---|
| 1252 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
| 1253 | for (Int idx=0; idx<numEntryPointOffsets; idx++) |
---|
[2] | 1254 | { |
---|
[56] | 1255 | entryPointOffset[ idx ] = ( pSubstreamSizes[ idx ] >> 3 ) ; |
---|
| 1256 | if ( entryPointOffset[ idx ] > maxOffset ) |
---|
[2] | 1257 | { |
---|
[56] | 1258 | maxOffset = entryPointOffset[ idx ]; |
---|
[2] | 1259 | } |
---|
| 1260 | } |
---|
[56] | 1261 | } |
---|
[2] | 1262 | |
---|
[56] | 1263 | 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] | 1264 | |
---|
[56] | 1265 | // Determine number of bits "offsetLenMinus1+1" required for entry point information |
---|
| 1266 | offsetLenMinus1 = 0; |
---|
| 1267 | while (1) |
---|
| 1268 | { |
---|
| 1269 | if (maxOffset >= (1 << offsetLenMinus1) ) |
---|
| 1270 | { |
---|
| 1271 | offsetLenMinus1++; |
---|
| 1272 | if ( offsetLenMinus1 > 32 ) |
---|
[2] | 1273 | { |
---|
[56] | 1274 | FATAL_ERROR_0("exceeded 32-bits", -1); |
---|
[2] | 1275 | } |
---|
| 1276 | } |
---|
[56] | 1277 | else |
---|
[2] | 1278 | { |
---|
[56] | 1279 | break; |
---|
[2] | 1280 | } |
---|
| 1281 | } |
---|
| 1282 | |
---|
[56] | 1283 | WRITE_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); |
---|
| 1284 | if (numEntryPointOffsets>0) |
---|
[2] | 1285 | { |
---|
[56] | 1286 | WRITE_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
[2] | 1287 | } |
---|
[56] | 1288 | |
---|
| 1289 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
[2] | 1290 | { |
---|
[56] | 1291 | if ( idx == 0 ) |
---|
| 1292 | { |
---|
| 1293 | // Adding sizes of NALU header and slice header information to entryPointOffset[ 0 ] |
---|
| 1294 | Int bitDistFromNALUHdrStart = m_pcBitIf->getNumberOfWrittenBits() + 16; |
---|
| 1295 | entryPointOffset[ idx ] += ( bitDistFromNALUHdrStart + numEntryPointOffsets*(offsetLenMinus1+1) ) >> 3; |
---|
| 1296 | } |
---|
| 1297 | WRITE_CODE(entryPointOffset[ idx ], offsetLenMinus1+1, "entry_point_offset"); |
---|
[2] | 1298 | } |
---|
| 1299 | |
---|
[56] | 1300 | delete [] entryPointOffset; |
---|
[2] | 1301 | } |
---|
[56] | 1302 | #else |
---|
| 1303 | Void TEncCavlc::codeSliceHeaderSubstreamTable( TComSlice* pcSlice ) |
---|
| 1304 | { |
---|
| 1305 | UInt uiNumSubstreams = pcSlice->getPPS()->getNumSubstreams(); |
---|
| 1306 | UInt*puiSubstreamSizes = pcSlice->getSubstreamSizes(); |
---|
[2] | 1307 | |
---|
[56] | 1308 | // Write header information for all substreams except the last. |
---|
| 1309 | for (UInt ui = 0; ui+1 < uiNumSubstreams; ui++) |
---|
[2] | 1310 | { |
---|
[56] | 1311 | UInt uiNumbits = puiSubstreamSizes[ui]; |
---|
[2] | 1312 | |
---|
[56] | 1313 | //the 2 first bits are used to give the size of the header |
---|
| 1314 | if ( uiNumbits < (1<<8) ) |
---|
[2] | 1315 | { |
---|
[56] | 1316 | xWriteCode(0, 2 ); |
---|
| 1317 | xWriteCode(uiNumbits, 8 ); |
---|
[2] | 1318 | } |
---|
[56] | 1319 | else if ( uiNumbits < (1<<16) ) |
---|
| 1320 | { |
---|
| 1321 | xWriteCode(1, 2 ); |
---|
| 1322 | xWriteCode(uiNumbits, 16 ); |
---|
| 1323 | } |
---|
| 1324 | else if ( uiNumbits < (1<<24) ) |
---|
| 1325 | { |
---|
| 1326 | xWriteCode(2, 2 ); |
---|
| 1327 | xWriteCode(uiNumbits, 24 ); |
---|
| 1328 | } |
---|
| 1329 | else if ( uiNumbits < (1<<31) ) |
---|
| 1330 | { |
---|
| 1331 | xWriteCode(3, 2 ); |
---|
| 1332 | xWriteCode(uiNumbits, 32 ); |
---|
| 1333 | } |
---|
| 1334 | else |
---|
| 1335 | { |
---|
| 1336 | printf("Error in codeSliceHeaderTable\n"); |
---|
| 1337 | exit(-1); |
---|
| 1338 | } |
---|
[2] | 1339 | } |
---|
| 1340 | } |
---|
[56] | 1341 | #endif |
---|
[2] | 1342 | |
---|
[56] | 1343 | Void TEncCavlc::codeTerminatingBit ( UInt uilsLast ) |
---|
[2] | 1344 | { |
---|
[56] | 1345 | } |
---|
[2] | 1346 | |
---|
[56] | 1347 | Void TEncCavlc::codeSliceFinish () |
---|
| 1348 | { |
---|
| 1349 | } |
---|
[2] | 1350 | |
---|
[56] | 1351 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
| 1352 | Void TEncCavlc::codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Int iNum ) |
---|
[2] | 1353 | #else |
---|
[56] | 1354 | Void TEncCavlc::codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
[2] | 1355 | #endif |
---|
[56] | 1356 | { |
---|
| 1357 | assert(0); |
---|
| 1358 | } |
---|
[2] | 1359 | |
---|
[56] | 1360 | Void TEncCavlc::codePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1361 | { |
---|
| 1362 | assert(0); |
---|
| 1363 | } |
---|
[2] | 1364 | |
---|
[56] | 1365 | Void TEncCavlc::codePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1366 | { |
---|
| 1367 | assert(0); |
---|
| 1368 | } |
---|
[2] | 1369 | |
---|
[56] | 1370 | Void TEncCavlc::codeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1371 | { |
---|
| 1372 | assert(0); |
---|
| 1373 | } |
---|
[2] | 1374 | |
---|
[56] | 1375 | Void TEncCavlc::codeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1376 | { |
---|
| 1377 | assert(0); |
---|
| 1378 | } |
---|
[2] | 1379 | |
---|
[56] | 1380 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 1381 | Void |
---|
| 1382 | TEncCavlc::codeResPredFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1383 | { |
---|
| 1384 | assert(0); |
---|
| 1385 | } |
---|
[2] | 1386 | #endif |
---|
| 1387 | |
---|
[56] | 1388 | Void TEncCavlc::codeAlfCtrlFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1389 | { |
---|
| 1390 | if (!m_bAlfCtrl) |
---|
| 1391 | { |
---|
| 1392 | return; |
---|
[2] | 1393 | } |
---|
[56] | 1394 | |
---|
| 1395 | if( pcCU->getDepth(uiAbsPartIdx) > m_uiMaxAlfCtrlDepth && !pcCU->isFirstAbsZorderIdxInDepth(uiAbsPartIdx, m_uiMaxAlfCtrlDepth)) |
---|
| 1396 | { |
---|
| 1397 | return; |
---|
| 1398 | } |
---|
| 1399 | |
---|
| 1400 | // get context function is here |
---|
| 1401 | UInt uiSymbol = pcCU->getAlfCtrlFlag( uiAbsPartIdx ) ? 1 : 0; |
---|
| 1402 | |
---|
| 1403 | xWriteFlag( uiSymbol ); |
---|
| 1404 | } |
---|
[2] | 1405 | |
---|
[56] | 1406 | Void TEncCavlc::codeApsExtensionFlag () |
---|
| 1407 | { |
---|
| 1408 | WRITE_FLAG(0, "aps_extension_flag"); |
---|
[2] | 1409 | } |
---|
| 1410 | |
---|
[56] | 1411 | Void TEncCavlc::codeAlfCtrlDepth() |
---|
| 1412 | { |
---|
| 1413 | if (!m_bAlfCtrl) |
---|
[2] | 1414 | { |
---|
[56] | 1415 | return; |
---|
[2] | 1416 | } |
---|
[56] | 1417 | |
---|
| 1418 | UInt uiDepth = m_uiMaxAlfCtrlDepth; |
---|
| 1419 | |
---|
| 1420 | xWriteUvlc(uiDepth); |
---|
| 1421 | } |
---|
[2] | 1422 | |
---|
[56] | 1423 | Void TEncCavlc::codeInterModeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiEncMode ) |
---|
| 1424 | { |
---|
| 1425 | assert(0); |
---|
| 1426 | } |
---|
[2] | 1427 | |
---|
[56] | 1428 | Void TEncCavlc::codeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1429 | { |
---|
| 1430 | assert(0); |
---|
| 1431 | } |
---|
[2] | 1432 | |
---|
[56] | 1433 | Void TEncCavlc::codeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1434 | { |
---|
| 1435 | assert(0); |
---|
| 1436 | } |
---|
[2] | 1437 | |
---|
[56] | 1438 | Void TEncCavlc::codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) |
---|
| 1439 | { |
---|
| 1440 | assert(0); |
---|
| 1441 | } |
---|
[2] | 1442 | |
---|
[56] | 1443 | Void TEncCavlc::codeQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) |
---|
| 1444 | { |
---|
| 1445 | assert(0); |
---|
| 1446 | } |
---|
[2] | 1447 | |
---|
[56] | 1448 | Void TEncCavlc::codeQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1449 | { |
---|
| 1450 | assert(0); |
---|
| 1451 | } |
---|
[2] | 1452 | |
---|
[56] | 1453 | #if BURST_IPCM |
---|
| 1454 | /** Code I_PCM information. |
---|
| 1455 | * \param pcCU pointer to CU |
---|
| 1456 | * \param uiAbsPartIdx CU index |
---|
| 1457 | * \param numIPCM the number of succesive IPCM blocks with the same size |
---|
| 1458 | * \param firstIPCMFlag |
---|
| 1459 | * \returns Void |
---|
| 1460 | */ |
---|
| 1461 | Void TEncCavlc::codeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, Int numIPCM, Bool firstIPCMFlag) |
---|
| 1462 | { |
---|
| 1463 | assert(0); |
---|
| 1464 | } |
---|
[2] | 1465 | #else |
---|
[56] | 1466 | /** Code I_PCM information. |
---|
| 1467 | * \param pcCU pointer to CU |
---|
| 1468 | * \param uiAbsPartIdx CU index |
---|
| 1469 | * \returns Void |
---|
| 1470 | * |
---|
| 1471 | * If I_PCM flag indicates that the CU is I_PCM, code its PCM alignment bits and codes. |
---|
| 1472 | */ |
---|
| 1473 | Void TEncCavlc::codeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx) |
---|
| 1474 | { |
---|
| 1475 | UInt uiIPCM = (pcCU->getIPCMFlag(uiAbsPartIdx) == true)? 1 : 0; |
---|
[2] | 1476 | |
---|
[56] | 1477 | xWriteFlag(uiIPCM); |
---|
[2] | 1478 | |
---|
[56] | 1479 | if (uiIPCM) |
---|
[2] | 1480 | { |
---|
[56] | 1481 | xWritePCMAlignZero(); |
---|
[2] | 1482 | |
---|
[56] | 1483 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
| 1484 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
| 1485 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
[2] | 1486 | |
---|
[56] | 1487 | Pel* piPCMSample; |
---|
| 1488 | UInt uiWidth; |
---|
| 1489 | UInt uiHeight; |
---|
| 1490 | UInt uiSampleBits; |
---|
| 1491 | UInt uiX, uiY; |
---|
[2] | 1492 | |
---|
[56] | 1493 | piPCMSample = pcCU->getPCMSampleY() + uiLumaOffset; |
---|
| 1494 | uiWidth = pcCU->getWidth(uiAbsPartIdx); |
---|
| 1495 | uiHeight = pcCU->getHeight(uiAbsPartIdx); |
---|
| 1496 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
| 1497 | |
---|
| 1498 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
[2] | 1499 | { |
---|
[56] | 1500 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
[2] | 1501 | { |
---|
[56] | 1502 | UInt uiSample = piPCMSample[uiX]; |
---|
| 1503 | |
---|
| 1504 | xWriteCode(uiSample, uiSampleBits); |
---|
[2] | 1505 | } |
---|
[56] | 1506 | piPCMSample += uiWidth; |
---|
[2] | 1507 | } |
---|
| 1508 | |
---|
[56] | 1509 | piPCMSample = pcCU->getPCMSampleCb() + uiChromaOffset; |
---|
| 1510 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
| 1511 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
| 1512 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
| 1513 | |
---|
| 1514 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
[2] | 1515 | { |
---|
[56] | 1516 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
[2] | 1517 | { |
---|
[56] | 1518 | UInt uiSample = piPCMSample[uiX]; |
---|
| 1519 | |
---|
| 1520 | xWriteCode(uiSample, uiSampleBits); |
---|
[2] | 1521 | } |
---|
[56] | 1522 | piPCMSample += uiWidth; |
---|
[2] | 1523 | } |
---|
| 1524 | |
---|
[56] | 1525 | piPCMSample = pcCU->getPCMSampleCr() + uiChromaOffset; |
---|
| 1526 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
| 1527 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
| 1528 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
| 1529 | |
---|
| 1530 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
[2] | 1531 | { |
---|
[56] | 1532 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
| 1533 | { |
---|
| 1534 | UInt uiSample = piPCMSample[uiX]; |
---|
| 1535 | |
---|
| 1536 | xWriteCode(uiSample, uiSampleBits); |
---|
| 1537 | } |
---|
| 1538 | piPCMSample += uiWidth; |
---|
[2] | 1539 | } |
---|
[56] | 1540 | } |
---|
| 1541 | } |
---|
[2] | 1542 | #endif |
---|
| 1543 | |
---|
[56] | 1544 | Void TEncCavlc::codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1545 | { |
---|
| 1546 | assert(0); |
---|
| 1547 | } |
---|
[2] | 1548 | |
---|
[56] | 1549 | Void TEncCavlc::codeIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1550 | { |
---|
| 1551 | assert(0); |
---|
[2] | 1552 | } |
---|
| 1553 | |
---|
[56] | 1554 | Void TEncCavlc::codeInterDir( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
[2] | 1555 | { |
---|
[56] | 1556 | assert(0); |
---|
| 1557 | } |
---|
[2] | 1558 | |
---|
[56] | 1559 | Void TEncCavlc::codeRefFrmIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
| 1560 | { |
---|
| 1561 | assert(0); |
---|
[2] | 1562 | } |
---|
| 1563 | |
---|
[56] | 1564 | Void TEncCavlc::codeMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
[2] | 1565 | { |
---|
[56] | 1566 | assert(0); |
---|
[2] | 1567 | } |
---|
| 1568 | |
---|
[56] | 1569 | Void TEncCavlc::codeDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1570 | { |
---|
| 1571 | Int iDQp = pcCU->getQP( uiAbsPartIdx ) - pcCU->getRefQP( uiAbsPartIdx ); |
---|
| 1572 | |
---|
| 1573 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1574 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
| 1575 | iDQp = (iDQp + 78 + qpBdOffsetY + (qpBdOffsetY/2)) % (52 + qpBdOffsetY) - 26 - (qpBdOffsetY/2); |
---|
| 1576 | #endif |
---|
| 1577 | |
---|
| 1578 | xWriteSvlc( iDQp ); |
---|
| 1579 | |
---|
| 1580 | return; |
---|
| 1581 | } |
---|
| 1582 | |
---|
| 1583 | Void TEncCavlc::codeCoeffNxN ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) |
---|
| 1584 | { |
---|
| 1585 | assert(0); |
---|
| 1586 | } |
---|
| 1587 | |
---|
| 1588 | Void TEncCavlc::codeAlfFlag( UInt uiCode ) |
---|
| 1589 | { |
---|
| 1590 | xWriteFlag( uiCode ); |
---|
| 1591 | } |
---|
| 1592 | |
---|
[2] | 1593 | Void TEncCavlc::codeAlfCtrlFlag( UInt uiSymbol ) |
---|
| 1594 | { |
---|
| 1595 | xWriteFlag( uiSymbol ); |
---|
| 1596 | } |
---|
| 1597 | |
---|
| 1598 | Void TEncCavlc::codeAlfUvlc( UInt uiCode ) |
---|
| 1599 | { |
---|
| 1600 | xWriteUvlc( uiCode ); |
---|
| 1601 | } |
---|
| 1602 | |
---|
| 1603 | Void TEncCavlc::codeAlfSvlc( Int iCode ) |
---|
| 1604 | { |
---|
| 1605 | xWriteSvlc( iCode ); |
---|
| 1606 | } |
---|
[56] | 1607 | #if LCU_SYNTAX_ALF |
---|
| 1608 | /** Code the fixed length code (smaller than one max value) in OSALF |
---|
| 1609 | * \param idx: coded value |
---|
| 1610 | * \param maxValue: max value |
---|
| 1611 | */ |
---|
| 1612 | Void TEncCavlc::codeAlfFixedLengthIdx( UInt idx, UInt maxValue) |
---|
[2] | 1613 | { |
---|
[56] | 1614 | UInt length = 0; |
---|
| 1615 | assert(idx<=maxValue); |
---|
[2] | 1616 | |
---|
[56] | 1617 | UInt temp = maxValue; |
---|
| 1618 | for(UInt i=0; i<32; i++) |
---|
| 1619 | { |
---|
| 1620 | if(temp&0x1) |
---|
| 1621 | { |
---|
| 1622 | length = i+1; |
---|
| 1623 | } |
---|
| 1624 | temp = (temp >> 1); |
---|
| 1625 | } |
---|
| 1626 | |
---|
| 1627 | if(length) |
---|
| 1628 | { |
---|
| 1629 | xWriteCode( idx, length ); |
---|
| 1630 | } |
---|
| 1631 | } |
---|
| 1632 | #endif |
---|
| 1633 | |
---|
| 1634 | Void TEncCavlc::codeSaoFlag( UInt uiCode ) |
---|
| 1635 | { |
---|
[2] | 1636 | xWriteFlag( uiCode ); |
---|
| 1637 | } |
---|
| 1638 | |
---|
[56] | 1639 | Void TEncCavlc::codeSaoUvlc( UInt uiCode ) |
---|
[2] | 1640 | { |
---|
| 1641 | xWriteUvlc( uiCode ); |
---|
| 1642 | } |
---|
| 1643 | |
---|
[56] | 1644 | Void TEncCavlc::codeSaoSvlc( Int iCode ) |
---|
[2] | 1645 | { |
---|
| 1646 | xWriteSvlc( iCode ); |
---|
| 1647 | } |
---|
[56] | 1648 | #if SAO_UNIT_INTERLEAVING |
---|
| 1649 | /** Code SAO run. |
---|
| 1650 | * \param uiCode |
---|
| 1651 | * \param maxValue |
---|
| 1652 | */ |
---|
| 1653 | Void TEncCavlc::codeSaoRun( UInt uiCode, UInt maxValue) |
---|
| 1654 | { |
---|
| 1655 | UInt uiLength = 0; |
---|
| 1656 | if (!maxValue) |
---|
| 1657 | { |
---|
| 1658 | return; |
---|
| 1659 | } |
---|
| 1660 | assert(uiCode<=maxValue); |
---|
[2] | 1661 | |
---|
[56] | 1662 | for(UInt i=0; i<32; i++) |
---|
| 1663 | { |
---|
| 1664 | if(maxValue&0x1) |
---|
| 1665 | { |
---|
| 1666 | uiLength = i+1; |
---|
| 1667 | } |
---|
| 1668 | maxValue = (maxValue >> 1); |
---|
| 1669 | } |
---|
| 1670 | WRITE_CODE( uiCode, uiLength, "sao_run_diff"); |
---|
| 1671 | } |
---|
[2] | 1672 | #endif |
---|
| 1673 | |
---|
[56] | 1674 | Void TEncCavlc::estBit( estBitsSbacStruct* pcEstBitsCabac, Int width, Int height, TextType eTType ) |
---|
[2] | 1675 | { |
---|
| 1676 | // printf("error : no VLC mode support in this version\n"); |
---|
| 1677 | return; |
---|
| 1678 | } |
---|
| 1679 | |
---|
| 1680 | // ==================================================================================================================== |
---|
| 1681 | // Protected member functions |
---|
| 1682 | // ==================================================================================================================== |
---|
| 1683 | |
---|
| 1684 | Void TEncCavlc::xWriteCode ( UInt uiCode, UInt uiLength ) |
---|
| 1685 | { |
---|
| 1686 | assert ( uiLength > 0 ); |
---|
| 1687 | m_pcBitIf->write( uiCode, uiLength ); |
---|
| 1688 | } |
---|
| 1689 | |
---|
| 1690 | Void TEncCavlc::xWriteUvlc ( UInt uiCode ) |
---|
| 1691 | { |
---|
| 1692 | UInt uiLength = 1; |
---|
| 1693 | UInt uiTemp = ++uiCode; |
---|
[56] | 1694 | |
---|
[2] | 1695 | assert ( uiTemp ); |
---|
[56] | 1696 | |
---|
[2] | 1697 | while( 1 != uiTemp ) |
---|
| 1698 | { |
---|
| 1699 | uiTemp >>= 1; |
---|
| 1700 | uiLength += 2; |
---|
| 1701 | } |
---|
[56] | 1702 | |
---|
| 1703 | //m_pcBitIf->write( uiCode, uiLength ); |
---|
| 1704 | // Take care of cases where uiLength > 32 |
---|
| 1705 | m_pcBitIf->write( 0, uiLength >> 1); |
---|
| 1706 | m_pcBitIf->write( uiCode, (uiLength+1) >> 1); |
---|
[2] | 1707 | } |
---|
| 1708 | |
---|
| 1709 | Void TEncCavlc::xWriteSvlc ( Int iCode ) |
---|
| 1710 | { |
---|
| 1711 | UInt uiCode; |
---|
[56] | 1712 | |
---|
[2] | 1713 | uiCode = xConvertToUInt( iCode ); |
---|
| 1714 | xWriteUvlc( uiCode ); |
---|
| 1715 | } |
---|
| 1716 | |
---|
| 1717 | Void TEncCavlc::xWriteFlag( UInt uiCode ) |
---|
| 1718 | { |
---|
| 1719 | m_pcBitIf->write( uiCode, 1 ); |
---|
| 1720 | } |
---|
| 1721 | |
---|
[56] | 1722 | /** Write PCM alignment bits. |
---|
| 1723 | * \returns Void |
---|
| 1724 | */ |
---|
| 1725 | Void TEncCavlc::xWritePCMAlignZero () |
---|
[2] | 1726 | { |
---|
[56] | 1727 | m_pcBitIf->writeAlignZero(); |
---|
[2] | 1728 | } |
---|
| 1729 | |
---|
| 1730 | Void TEncCavlc::xWriteUnaryMaxSymbol( UInt uiSymbol, UInt uiMaxSymbol ) |
---|
| 1731 | { |
---|
| 1732 | if (uiMaxSymbol == 0) |
---|
| 1733 | { |
---|
| 1734 | return; |
---|
| 1735 | } |
---|
| 1736 | xWriteFlag( uiSymbol ? 1 : 0 ); |
---|
| 1737 | if ( uiSymbol == 0 ) |
---|
| 1738 | { |
---|
| 1739 | return; |
---|
| 1740 | } |
---|
[56] | 1741 | |
---|
[2] | 1742 | Bool bCodeLast = ( uiMaxSymbol > uiSymbol ); |
---|
[56] | 1743 | |
---|
[2] | 1744 | while( --uiSymbol ) |
---|
| 1745 | { |
---|
| 1746 | xWriteFlag( 1 ); |
---|
| 1747 | } |
---|
| 1748 | if( bCodeLast ) |
---|
| 1749 | { |
---|
| 1750 | xWriteFlag( 0 ); |
---|
| 1751 | } |
---|
| 1752 | return; |
---|
| 1753 | } |
---|
| 1754 | |
---|
| 1755 | Void TEncCavlc::xWriteExGolombLevel( UInt uiSymbol ) |
---|
| 1756 | { |
---|
| 1757 | if( uiSymbol ) |
---|
| 1758 | { |
---|
| 1759 | xWriteFlag( 1 ); |
---|
| 1760 | UInt uiCount = 0; |
---|
| 1761 | Bool bNoExGo = (uiSymbol < 13); |
---|
[56] | 1762 | |
---|
[2] | 1763 | while( --uiSymbol && ++uiCount < 13 ) |
---|
| 1764 | { |
---|
| 1765 | xWriteFlag( 1 ); |
---|
| 1766 | } |
---|
| 1767 | if( bNoExGo ) |
---|
| 1768 | { |
---|
| 1769 | xWriteFlag( 0 ); |
---|
| 1770 | } |
---|
| 1771 | else |
---|
| 1772 | { |
---|
| 1773 | xWriteEpExGolomb( uiSymbol, 0 ); |
---|
| 1774 | } |
---|
| 1775 | } |
---|
| 1776 | else |
---|
| 1777 | { |
---|
| 1778 | xWriteFlag( 0 ); |
---|
| 1779 | } |
---|
| 1780 | return; |
---|
| 1781 | } |
---|
| 1782 | |
---|
| 1783 | Void TEncCavlc::xWriteEpExGolomb( UInt uiSymbol, UInt uiCount ) |
---|
| 1784 | { |
---|
| 1785 | while( uiSymbol >= (UInt)(1<<uiCount) ) |
---|
| 1786 | { |
---|
| 1787 | xWriteFlag( 1 ); |
---|
| 1788 | uiSymbol -= 1<<uiCount; |
---|
| 1789 | uiCount ++; |
---|
| 1790 | } |
---|
| 1791 | xWriteFlag( 0 ); |
---|
| 1792 | while( uiCount-- ) |
---|
| 1793 | { |
---|
| 1794 | xWriteFlag( (uiSymbol>>uiCount) & 1 ); |
---|
| 1795 | } |
---|
| 1796 | return; |
---|
| 1797 | } |
---|
| 1798 | |
---|
[56] | 1799 | /** code explicit wp tables |
---|
| 1800 | * \param TComSlice* pcSlice |
---|
| 1801 | * \returns Void |
---|
[2] | 1802 | */ |
---|
[56] | 1803 | Void TEncCavlc::xCodePredWeightTable( TComSlice* pcSlice ) |
---|
[2] | 1804 | { |
---|
[56] | 1805 | wpScalingParam *wp; |
---|
| 1806 | Bool bChroma = true; // color always present in HEVC ? |
---|
| 1807 | Int iNbRef = (pcSlice->getSliceType() == B_SLICE ) ? (2) : (1); |
---|
| 1808 | Bool bDenomCoded = false; |
---|
[2] | 1809 | |
---|
[56] | 1810 | UInt uiMode = 0; |
---|
| 1811 | if ( (pcSlice->getSliceType()==P_SLICE && pcSlice->getPPS()->getUseWP()) || (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPredIdc()==1 && pcSlice->getRefPicListCombinationFlag()==0 ) ) |
---|
| 1812 | uiMode = 1; // explicit |
---|
| 1813 | else if ( pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPredIdc()==2 ) |
---|
| 1814 | uiMode = 2; // implicit (does not use this mode in this syntax) |
---|
| 1815 | if (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPredIdc()==1 && pcSlice->getRefPicListCombinationFlag()) |
---|
| 1816 | uiMode = 3; // combined explicit |
---|
| 1817 | if(uiMode == 1) |
---|
[2] | 1818 | { |
---|
[56] | 1819 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
[2] | 1820 | { |
---|
[56] | 1821 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
| 1822 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
[2] | 1823 | { |
---|
[56] | 1824 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 1825 | if ( !bDenomCoded ) |
---|
[2] | 1826 | { |
---|
[56] | 1827 | Int iDeltaDenom; |
---|
| 1828 | WRITE_UVLC( wp[0].uiLog2WeightDenom, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
[2] | 1829 | |
---|
[56] | 1830 | if( bChroma ) |
---|
[2] | 1831 | { |
---|
[56] | 1832 | iDeltaDenom = (wp[1].uiLog2WeightDenom - wp[0].uiLog2WeightDenom); |
---|
| 1833 | WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
[2] | 1834 | } |
---|
[56] | 1835 | bDenomCoded = true; |
---|
| 1836 | } |
---|
[2] | 1837 | |
---|
[56] | 1838 | WRITE_FLAG( wp[0].bPresentFlag, "luma_weight_lX_flag" ); // u(1): luma_weight_lX_flag |
---|
[2] | 1839 | |
---|
[56] | 1840 | if ( wp[0].bPresentFlag ) |
---|
| 1841 | { |
---|
| 1842 | Int iDeltaWeight = (wp[0].iWeight - (1<<wp[0].uiLog2WeightDenom)); |
---|
| 1843 | WRITE_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_lX |
---|
| 1844 | WRITE_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_lX |
---|
| 1845 | } |
---|
[2] | 1846 | |
---|
[56] | 1847 | if ( bChroma ) |
---|
| 1848 | { |
---|
| 1849 | WRITE_FLAG( wp[1].bPresentFlag, "chroma_weight_lX_flag" ); // u(1): chroma_weight_lX_flag |
---|
[2] | 1850 | |
---|
[56] | 1851 | if ( wp[1].bPresentFlag ) |
---|
[2] | 1852 | { |
---|
[56] | 1853 | for ( Int j=1 ; j<3 ; j++ ) |
---|
[2] | 1854 | { |
---|
[56] | 1855 | Int iDeltaWeight = (wp[j].iWeight - (1<<wp[1].uiLog2WeightDenom)); |
---|
| 1856 | WRITE_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): delta_chroma_weight_lX |
---|
| 1857 | |
---|
| 1858 | Int iDeltaChroma = (wp[j].iOffset + ( ( (g_uiIBDI_MAX>>1)*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) - (g_uiIBDI_MAX>>1)); |
---|
| 1859 | WRITE_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_lX |
---|
[2] | 1860 | } |
---|
| 1861 | } |
---|
| 1862 | } |
---|
| 1863 | } |
---|
| 1864 | } |
---|
| 1865 | } |
---|
[56] | 1866 | else if (uiMode == 3) |
---|
[2] | 1867 | { |
---|
[56] | 1868 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(REF_PIC_LIST_C) ; iRefIdx++ ) |
---|
| 1869 | { |
---|
| 1870 | RefPicList eRefPicList = (RefPicList)pcSlice->getListIdFromIdxOfLC(iRefIdx); |
---|
| 1871 | Int iCombRefIdx = pcSlice->getRefIdxFromIdxOfLC(iRefIdx); |
---|
[2] | 1872 | |
---|
[56] | 1873 | pcSlice->getWpScaling(eRefPicList, iCombRefIdx, wp); |
---|
| 1874 | if ( !bDenomCoded ) |
---|
[2] | 1875 | { |
---|
[56] | 1876 | Int iDeltaDenom; |
---|
| 1877 | WRITE_UVLC( wp[0].uiLog2WeightDenom, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
| 1878 | |
---|
| 1879 | if( bChroma ) |
---|
| 1880 | { |
---|
| 1881 | iDeltaDenom = (wp[1].uiLog2WeightDenom - wp[0].uiLog2WeightDenom); |
---|
| 1882 | WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
| 1883 | } |
---|
| 1884 | bDenomCoded = true; |
---|
[2] | 1885 | } |
---|
| 1886 | |
---|
[56] | 1887 | WRITE_FLAG( wp[0].bPresentFlag, "luma_weight_lc_flag" ); // u(1): luma_weight_lc_flag |
---|
[2] | 1888 | |
---|
[56] | 1889 | if ( wp[0].bPresentFlag ) |
---|
| 1890 | { |
---|
| 1891 | Int iDeltaWeight = (wp[0].iWeight - (1<<wp[0].uiLog2WeightDenom)); |
---|
| 1892 | WRITE_SVLC( iDeltaWeight, "delta_luma_weight_lc" ); // se(v): delta_luma_weight_lc |
---|
| 1893 | WRITE_SVLC( wp[0].iOffset, "luma_offset_lc" ); // se(v): luma_offset_lc |
---|
| 1894 | } |
---|
| 1895 | if ( bChroma ) |
---|
| 1896 | { |
---|
| 1897 | WRITE_FLAG( wp[1].bPresentFlag, "chroma_weight_lc_flag" ); // u(1): luma_weight_lc_flag |
---|
[2] | 1898 | |
---|
[56] | 1899 | if ( wp[1].bPresentFlag ) |
---|
| 1900 | { |
---|
| 1901 | for ( Int j=1 ; j<3 ; j++ ) |
---|
| 1902 | { |
---|
| 1903 | Int iDeltaWeight = (wp[j].iWeight - (1<<wp[1].uiLog2WeightDenom)); |
---|
| 1904 | WRITE_SVLC( iDeltaWeight, "delta_chroma_weight_lc" ); // se(v): delta_chroma_weight_lc |
---|
[2] | 1905 | |
---|
[56] | 1906 | Int iDeltaChroma = (wp[j].iOffset + ( ( (g_uiIBDI_MAX>>1)*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) - (g_uiIBDI_MAX>>1)); |
---|
| 1907 | WRITE_SVLC( iDeltaChroma, "delta_chroma_offset_lc" ); // se(v): delta_chroma_offset_lc |
---|
| 1908 | } |
---|
| 1909 | } |
---|
| 1910 | } |
---|
[2] | 1911 | } |
---|
| 1912 | } |
---|
[56] | 1913 | } |
---|
[2] | 1914 | |
---|
[56] | 1915 | /** code quantization matrix |
---|
| 1916 | * \param scalingList quantization matrix information |
---|
| 1917 | */ |
---|
| 1918 | Void TEncCavlc::codeScalingList( TComScalingList* scalingList ) |
---|
| 1919 | { |
---|
| 1920 | UInt listId,sizeId; |
---|
| 1921 | Bool scalingListPredModeFlag; |
---|
[2] | 1922 | |
---|
[56] | 1923 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 1924 | Int startBit; |
---|
| 1925 | Int startTotalBit; |
---|
| 1926 | startBit = m_pcBitIf->getNumberOfWrittenBits(); |
---|
| 1927 | startTotalBit = m_pcBitIf->getNumberOfWrittenBits(); |
---|
[2] | 1928 | #endif |
---|
| 1929 | |
---|
[56] | 1930 | WRITE_FLAG( scalingList->getScalingListPresentFlag (), "scaling_list_present_flag" ); |
---|
| 1931 | |
---|
| 1932 | if(scalingList->getScalingListPresentFlag () == false) |
---|
[2] | 1933 | { |
---|
[56] | 1934 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 1935 | printf("Header Bit %d\n",m_pcBitIf->getNumberOfWrittenBits()-startBit); |
---|
[2] | 1936 | #endif |
---|
[56] | 1937 | //for each size |
---|
| 1938 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
[2] | 1939 | { |
---|
[56] | 1940 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
[2] | 1941 | { |
---|
[56] | 1942 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 1943 | startBit = m_pcBitIf->getNumberOfWrittenBits(); |
---|
[2] | 1944 | #endif |
---|
[56] | 1945 | scalingListPredModeFlag = scalingList->checkPredMode( sizeId, listId ); |
---|
| 1946 | WRITE_FLAG( scalingListPredModeFlag, "scaling_list_pred_mode_flag" ); |
---|
| 1947 | if(!scalingListPredModeFlag)// Copy Mode |
---|
[2] | 1948 | { |
---|
[56] | 1949 | WRITE_UVLC( (Int)listId - (Int)scalingList->getRefMatrixId (sizeId,listId) - 1, "scaling_list_pred_matrix_id_delta"); |
---|
[2] | 1950 | } |
---|
[56] | 1951 | else// DPCM Mode |
---|
[2] | 1952 | { |
---|
[56] | 1953 | xCodeScalingList(scalingList, sizeId, listId); |
---|
[2] | 1954 | } |
---|
[56] | 1955 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 1956 | printf("Matrix [%d][%d] Bit %d\n",sizeId,listId,m_pcBitIf->getNumberOfWrittenBits() - startBit); |
---|
[2] | 1957 | #endif |
---|
| 1958 | } |
---|
| 1959 | } |
---|
| 1960 | } |
---|
[56] | 1961 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 1962 | else |
---|
[2] | 1963 | { |
---|
[56] | 1964 | printf("Header Bit %d\n",m_pcBitIf->getNumberOfWrittenBits()-startTotalBit); |
---|
[2] | 1965 | } |
---|
[56] | 1966 | printf("Total Bit %d\n",m_pcBitIf->getNumberOfWrittenBits()-startTotalBit); |
---|
| 1967 | #endif |
---|
[2] | 1968 | return; |
---|
| 1969 | } |
---|
[56] | 1970 | /** code DPCM |
---|
| 1971 | * \param scalingList quantization matrix information |
---|
| 1972 | * \param sizeIdc size index |
---|
| 1973 | * \param listIdc list index |
---|
| 1974 | */ |
---|
| 1975 | Void TEncCavlc::xCodeScalingList(TComScalingList* scalingList, UInt sizeId, UInt listId) |
---|
[2] | 1976 | { |
---|
[56] | 1977 | #if SCALING_LIST |
---|
| 1978 | Int coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
| 1979 | UInt* scan = g_auiFrameScanXY [ (sizeId == 0)? 1 : 2]; |
---|
[2] | 1980 | #else |
---|
[56] | 1981 | Int coefNum = (Int)g_scalingListSize[sizeId]; |
---|
| 1982 | UInt* scan = g_auiFrameScanXY [ sizeId + 1]; |
---|
[2] | 1983 | #endif |
---|
[56] | 1984 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
| 1985 | Int data; |
---|
| 1986 | Int *src = scalingList->getScalingListAddress(sizeId, listId); |
---|
| 1987 | #if SCALING_LIST |
---|
| 1988 | if(sizeId > SCALING_LIST_8x8 && scalingList->getUseDefaultScalingMatrixFlag(sizeId,listId)) |
---|
[2] | 1989 | { |
---|
[56] | 1990 | WRITE_SVLC( -8, "scaling_list_dc_coef_minus8"); |
---|
[2] | 1991 | } |
---|
[56] | 1992 | else if(sizeId < SCALING_LIST_16x16 && scalingList->getUseDefaultScalingMatrixFlag(sizeId,listId)) |
---|
[2] | 1993 | { |
---|
[56] | 1994 | WRITE_SVLC( -8, "scaling_list_delta_coef"); |
---|
[2] | 1995 | } |
---|
[56] | 1996 | else |
---|
[2] | 1997 | { |
---|
[56] | 1998 | if( sizeId > SCALING_LIST_8x8 ) |
---|
[2] | 1999 | { |
---|
[56] | 2000 | WRITE_SVLC( scalingList->getScalingListDC(sizeId,listId) - 8, "scaling_list_dc_coef_minus8"); |
---|
[2] | 2001 | } |
---|
[56] | 2002 | for(Int i=0;i<coefNum;i++) |
---|
[2] | 2003 | { |
---|
[56] | 2004 | data = src[scan[i]] - nextCoef; |
---|
| 2005 | nextCoef = src[scan[i]]; |
---|
| 2006 | if(data > 127) |
---|
[2] | 2007 | { |
---|
[56] | 2008 | data = data - 256; |
---|
[2] | 2009 | } |
---|
[56] | 2010 | if(data < -128) |
---|
[2] | 2011 | { |
---|
[56] | 2012 | data = data + 256; |
---|
[2] | 2013 | } |
---|
| 2014 | |
---|
[56] | 2015 | WRITE_SVLC( data, "scaling_list_delta_coef"); |
---|
[2] | 2016 | } |
---|
| 2017 | } |
---|
[56] | 2018 | #else |
---|
| 2019 | for(Int i=0;i<coefNum;i++) |
---|
[2] | 2020 | { |
---|
[56] | 2021 | data = src[scan[i]] - nextCoef; |
---|
| 2022 | nextCoef = src[scan[i]]; |
---|
| 2023 | if(data > 127) |
---|
[2] | 2024 | { |
---|
[56] | 2025 | data = data - 256; |
---|
[2] | 2026 | } |
---|
[56] | 2027 | if(data < -128) |
---|
[2] | 2028 | { |
---|
[56] | 2029 | data = data + 256; |
---|
[2] | 2030 | } |
---|
[56] | 2031 | |
---|
| 2032 | WRITE_SVLC( data, "delta_coef"); |
---|
[2] | 2033 | } |
---|
[56] | 2034 | #endif |
---|
[2] | 2035 | } |
---|
[56] | 2036 | Bool TComScalingList::checkPredMode(UInt sizeId, UInt listId) |
---|
| 2037 | { |
---|
| 2038 | for(Int predListIdx = (Int)listId -1 ; predListIdx >= 0; predListIdx--) |
---|
| 2039 | { |
---|
| 2040 | #if SCALING_LIST |
---|
| 2041 | if( !memcmp(getScalingListAddress(sizeId,listId),getScalingListAddress(sizeId, predListIdx),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
| 2042 | && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == getScalingListDC(sizeId,predListIdx)))) // check DC value |
---|
| 2043 | #else |
---|
| 2044 | if( !memcmp(getScalingListAddress(sizeId,listId),getScalingListAddress(sizeId, predListIdx),sizeof(Int)*(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
[2] | 2045 | #endif |
---|
[56] | 2046 | { |
---|
| 2047 | setRefMatrixId(sizeId, listId, predListIdx); |
---|
| 2048 | return false; |
---|
[2] | 2049 | } |
---|
| 2050 | } |
---|
[56] | 2051 | return true; |
---|
[2] | 2052 | } |
---|
[56] | 2053 | //! \} |
---|