[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"); |
---|
[2] | 163 | } |
---|
[56] | 164 | Void TEncCavlc::codeAPSAlflag(UInt uiCode) |
---|
| 165 | { |
---|
| 166 | WRITE_FLAG(uiCode, "aps_adaptive_loop_filter_flag"); |
---|
| 167 | } |
---|
[2] | 168 | |
---|
[56] | 169 | Void TEncCavlc::codeDFFlag(UInt uiCode, const Char *pSymbolName) |
---|
[42] | 170 | { |
---|
[56] | 171 | WRITE_FLAG(uiCode, pSymbolName); |
---|
[42] | 172 | } |
---|
[56] | 173 | Void TEncCavlc::codeDFSvlc(Int iCode, const Char *pSymbolName) |
---|
[2] | 174 | { |
---|
[56] | 175 | WRITE_SVLC(iCode, pSymbolName); |
---|
[2] | 176 | } |
---|
| 177 | |
---|
[56] | 178 | Void TEncCavlc::codeShortTermRefPicSet( TComSPS* pcSPS, TComReferencePictureSet* rps ) |
---|
| 179 | { |
---|
| 180 | #if PRINT_RPS_INFO |
---|
| 181 | int lastBits = getNumberOfWrittenBits(); |
---|
[2] | 182 | #endif |
---|
[56] | 183 | WRITE_FLAG( rps->getInterRPSPrediction(), "inter_ref_pic_set_prediction_flag" ); // inter_RPS_prediction_flag |
---|
| 184 | if (rps->getInterRPSPrediction()) |
---|
| 185 | { |
---|
| 186 | Int deltaRPS = rps->getDeltaRPS(); |
---|
| 187 | WRITE_UVLC( rps->getDeltaRIdxMinus1(), "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1 |
---|
| 188 | WRITE_CODE( (deltaRPS >=0 ? 0: 1), 1, "delta_rps_sign" ); //delta_rps_sign |
---|
| 189 | WRITE_UVLC( abs(deltaRPS) - 1, "abs_delta_rps_minus1"); // absolute delta RPS minus 1 |
---|
[2] | 190 | |
---|
[56] | 191 | for(Int j=0; j < rps->getNumRefIdc(); j++) |
---|
| 192 | { |
---|
| 193 | Int refIdc = rps->getRefIdc(j); |
---|
| 194 | WRITE_CODE( (refIdc==1? 1: 0), 1, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 |
---|
| 195 | if (refIdc != 1) |
---|
| 196 | { |
---|
| 197 | WRITE_CODE( refIdc>>1, 1, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise. |
---|
| 198 | } |
---|
| 199 | } |
---|
[2] | 200 | } |
---|
[56] | 201 | else |
---|
[2] | 202 | { |
---|
[56] | 203 | WRITE_UVLC( rps->getNumberOfNegativePictures(), "num_negative_pics" ); |
---|
| 204 | WRITE_UVLC( rps->getNumberOfPositivePictures(), "num_positive_pics" ); |
---|
| 205 | Int prev = 0; |
---|
| 206 | for(Int j=0 ; j < rps->getNumberOfNegativePictures(); j++) |
---|
[2] | 207 | { |
---|
[56] | 208 | WRITE_UVLC( prev-rps->getDeltaPOC(j)-1, "delta_poc_s0_minus1" ); |
---|
| 209 | prev = rps->getDeltaPOC(j); |
---|
| 210 | WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s0_flag"); |
---|
[2] | 211 | } |
---|
[56] | 212 | prev = 0; |
---|
| 213 | for(Int j=rps->getNumberOfNegativePictures(); j < rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); j++) |
---|
[2] | 214 | { |
---|
[56] | 215 | WRITE_UVLC( rps->getDeltaPOC(j)-prev-1, "delta_poc_s1_minus1" ); |
---|
| 216 | prev = rps->getDeltaPOC(j); |
---|
| 217 | WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s1_flag" ); |
---|
[2] | 218 | } |
---|
| 219 | } |
---|
[56] | 220 | |
---|
| 221 | #if PRINT_RPS_INFO |
---|
| 222 | printf("irps=%d (%2d bits) ", rps->getInterRPSPrediction(), getNumberOfWrittenBits() - lastBits); |
---|
| 223 | rps->printDeltaPOC(); |
---|
| 224 | #endif |
---|
[2] | 225 | } |
---|
| 226 | |
---|
[56] | 227 | |
---|
| 228 | Void TEncCavlc::codePPS( TComPPS* pcPPS ) |
---|
[2] | 229 | { |
---|
[56] | 230 | #if ENC_DEC_TRACE |
---|
| 231 | xTracePPSHeader (pcPPS); |
---|
[42] | 232 | #endif |
---|
[56] | 233 | |
---|
| 234 | WRITE_UVLC( pcPPS->getPPSId(), "pic_parameter_set_id" ); |
---|
| 235 | WRITE_UVLC( pcPPS->getSPSId(), "seq_parameter_set_id" ); |
---|
[2] | 236 | |
---|
[56] | 237 | WRITE_FLAG( pcPPS->getSignHideFlag(), "sign_data_hiding_flag" ); |
---|
| 238 | if( pcPPS->getSignHideFlag() ) |
---|
[2] | 239 | { |
---|
[56] | 240 | WRITE_CODE(pcPPS->getTSIG(), 4, "sign_hiding_threshold"); |
---|
[2] | 241 | } |
---|
[56] | 242 | #if CABAC_INIT_FLAG |
---|
| 243 | WRITE_FLAG( pcPPS->getCabacInitPresentFlag() ? 1 : 0, "cabac_init_present_flag" ); |
---|
| 244 | #endif |
---|
| 245 | // entropy_coding_mode_flag |
---|
| 246 | // We code the entropy_coding_mode_flag, it's needed for tests. |
---|
| 247 | WRITE_FLAG( pcPPS->getEntropyCodingMode() ? 1 : 0, "entropy_coding_mode_flag" ); |
---|
| 248 | if (pcPPS->getEntropyCodingMode()) |
---|
[2] | 249 | { |
---|
| 250 | } |
---|
[56] | 251 | // num_ref_idx_l0_default_active_minus1 |
---|
| 252 | // num_ref_idx_l1_default_active_minus1 |
---|
| 253 | WRITE_SVLC( pcPPS->getPicInitQPMinus26(), "pic_init_qp_minus26"); |
---|
| 254 | WRITE_FLAG( pcPPS->getConstrainedIntraPred() ? 1 : 0, "constrained_intra_pred_flag" ); |
---|
| 255 | WRITE_FLAG( pcPPS->getEnableTMVPFlag() ? 1 : 0, "enable_temporal_mvp_flag" ); |
---|
| 256 | WRITE_CODE( pcPPS->getSliceGranularity(), 2, "slice_granularity"); |
---|
| 257 | WRITE_UVLC( pcPPS->getMaxCuDQPDepth() + pcPPS->getUseDQP(), "max_cu_qp_delta_depth" ); |
---|
[2] | 258 | |
---|
[56] | 259 | WRITE_SVLC( pcPPS->getChromaQpOffset(), "chroma_qp_offset" ); |
---|
| 260 | WRITE_SVLC( pcPPS->getChromaQpOffset2nd(), "chroma_qp_offset_2nd" ); |
---|
[2] | 261 | |
---|
[56] | 262 | WRITE_FLAG( pcPPS->getUseWP() ? 1 : 0, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) |
---|
| 263 | WRITE_CODE( pcPPS->getWPBiPredIdc(), 2, "weighted_bipred_idc" ); // Use of Weighting Bi-Prediction (B_SLICE) |
---|
| 264 | WRITE_FLAG( pcPPS->getOutputFlagPresentFlag() ? 1 : 0, "output_flag_present_flag" ); |
---|
| 265 | if(pcPPS->getSPS()->getTilesOrEntropyCodingSyncIdc()==1) |
---|
| 266 | { |
---|
| 267 | WRITE_FLAG( pcPPS->getColumnRowInfoPresent(), "tile_info_present_flag" ); |
---|
| 268 | WRITE_FLAG( pcPPS->getTileBehaviorControlPresentFlag(), "tile_control_present_flag"); |
---|
| 269 | if( pcPPS->getColumnRowInfoPresent() == 1 ) |
---|
[2] | 270 | { |
---|
[56] | 271 | WRITE_UVLC( pcPPS->getNumColumnsMinus1(), "num_tile_columns_minus1" ); |
---|
| 272 | WRITE_UVLC( pcPPS->getNumRowsMinus1(), "num_tile_rows_minus1" ); |
---|
| 273 | WRITE_FLAG( pcPPS->getUniformSpacingIdr(), "uniform_spacing_flag" ); |
---|
| 274 | if( pcPPS->getUniformSpacingIdr() == 0 ) |
---|
[2] | 275 | { |
---|
[56] | 276 | for(UInt i=0; i<pcPPS->getNumColumnsMinus1(); i++) |
---|
[2] | 277 | { |
---|
[56] | 278 | WRITE_UVLC( pcPPS->getColumnWidth(i), "column_width" ); |
---|
[2] | 279 | } |
---|
[56] | 280 | for(UInt i=0; i<pcPPS->getNumRowsMinus1(); i++) |
---|
[2] | 281 | { |
---|
[56] | 282 | WRITE_UVLC( pcPPS->getRowHeight(i), "row_height" ); |
---|
[2] | 283 | } |
---|
| 284 | } |
---|
[56] | 285 | } |
---|
[2] | 286 | |
---|
[56] | 287 | if(pcPPS->getTileBehaviorControlPresentFlag() == 1) |
---|
[2] | 288 | { |
---|
[56] | 289 | Int iNumColTilesMinus1 = (pcPPS->getColumnRowInfoPresent() == 1)?(pcPPS->getNumColumnsMinus1()):(pcPPS->getSPS()->getNumColumnsMinus1()); |
---|
| 290 | Int iNumRowTilesMinus1 = (pcPPS->getColumnRowInfoPresent() == 1)?(pcPPS->getNumColumnsMinus1()):(pcPPS->getSPS()->getNumRowsMinus1()); |
---|
[2] | 291 | |
---|
[56] | 292 | if(iNumColTilesMinus1 !=0 || iNumRowTilesMinus1 !=0) |
---|
[2] | 293 | { |
---|
[56] | 294 | WRITE_FLAG( pcPPS->getLFCrossTileBoundaryFlag()?1 : 0, "loop_filter_across_tile_flag"); |
---|
[2] | 295 | } |
---|
| 296 | } |
---|
| 297 | } |
---|
[56] | 298 | else if(pcPPS->getSPS()->getTilesOrEntropyCodingSyncIdc()==2) |
---|
[2] | 299 | { |
---|
[56] | 300 | WRITE_UVLC( pcPPS->getNumSubstreams()-1, "num_substreams_minus1" ); |
---|
[2] | 301 | } |
---|
| 302 | |
---|
[56] | 303 | WRITE_FLAG( pcPPS->getDeblockingFilterControlPresent()?1 : 0, "deblocking_filter_control_present_flag"); |
---|
| 304 | WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2"); |
---|
| 305 | WRITE_FLAG( 0, "pps_extension_flag" ); |
---|
[2] | 306 | } |
---|
| 307 | |
---|
[210] | 308 | #if QC_MVHEVC_B0046 |
---|
| 309 | Void TEncCavlc::codeVPS( TComVPS* pcVPS ) |
---|
| 310 | { |
---|
| 311 | WRITE_CODE( pcVPS->getVPSId(), 4, "video_parameter_set_id" ); |
---|
| 312 | WRITE_FLAG( pcVPS->getTemporalNestingFlag() -1, "temporal_id_nesting_flag" ); |
---|
| 313 | WRITE_CODE( 0, 2, "vps_reserved_zero_2bits" ); |
---|
| 314 | WRITE_CODE( pcVPS->getMaxLayers() - 1, 6, "vps_max_layers_minus1" ); |
---|
| 315 | WRITE_CODE( pcVPS->getMaxTLayers() - 1, 3, "vps_max_sub_layers_minus1" ); |
---|
| 316 | //to be determined |
---|
| 317 | //profile_tier_level( 1, vps_max_sub_layers_minus1 ); |
---|
| 318 | //to be modified |
---|
| 319 | WRITE_CODE( 0, 12, "vps_extension_offset" ); |
---|
| 320 | for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
| 321 | { |
---|
| 322 | WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i), "max_dec_pic_buffering[i]" ); |
---|
| 323 | WRITE_UVLC( pcVPS->getNumReorderPics(i), "num_reorder_pics[i]" ); |
---|
| 324 | WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i), "max_latency_increase[i]" ); |
---|
| 325 | } |
---|
| 326 | //!!!waste one bit: 3-view, 3; 2-view or more views: 1 |
---|
| 327 | WRITE_UVLC(pcVPS->getNumHRDParameters(), "vps_num_hrd_parameters" ); |
---|
| 328 | assert(pcVPS->getNumHRDParameters()==0); |
---|
| 329 | for ( UInt i = 0; i < pcVPS->getNumHRDParameters(); i ++) |
---|
| 330 | { |
---|
| 331 | // if( i > 0 ) |
---|
| 332 | //{ |
---|
| 333 | // WRITE_UVLC (0, "op_num_layer_id_values_minus1[ opIdx ]"); |
---|
| 334 | // for( i = 0; i <= op_num_layer_id_values_minus1[ opIdx ]; i++ ) |
---|
| 335 | // WRITE_CODE(0, 6, "op_layer_id[ opIdx ][ i ]"); |
---|
| 336 | //} |
---|
| 337 | //hrd_parameters( i = = 0, vps_max_sub_layers_minus1 ); |
---|
| 338 | } |
---|
| 339 | WRITE_CODE( 1, 1, "bit_equal_to_one" ); |
---|
| 340 | //btye aligned |
---|
| 341 | m_pcBitIf->writeAlignOne(); |
---|
| 342 | |
---|
| 343 | if(pcVPS->getMaxLayers() == 3) |
---|
| 344 | pcVPS->setNumAddiLayerOperationPoints (pcVPS->getMaxLayers()); //may be configured |
---|
| 345 | else |
---|
| 346 | pcVPS->setNumAddiLayerOperationPoints (1); |
---|
| 347 | pcVPS->setNumAddiProLevelSets (1); |
---|
| 348 | WRITE_CODE( pcVPS->getNumAddiLayerOperationPoints(), 8, "num_additional_layer_operation_points" ); |
---|
| 349 | WRITE_CODE( pcVPS->getNumAddiProLevelSets(), 8, "num_additional_profile_level_sets" ); |
---|
| 350 | for(UInt i=0; i <= pcVPS->getMaxLayers()-1; i++) |
---|
| 351 | { |
---|
| 352 | WRITE_CODE( 0, 4, "num_types_zero_4bits[i]" ); |
---|
| 353 | WRITE_CODE( 0, 4, "type_zero_4bits[i]" ); |
---|
| 354 | WRITE_CODE( pcVPS->getViewId(i), 8, "view_id[i]" ); |
---|
| 355 | if(i) |
---|
| 356 | { |
---|
| 357 | WRITE_CODE( pcVPS->getNumDirectRefLayer(i), 6, "num_direct_ref_layers[ i ]" ); |
---|
| 358 | for (UInt j = 0; j< pcVPS->getNumDirectRefLayer(i); j++) |
---|
| 359 | { |
---|
| 360 | WRITE_CODE( pcVPS->getDirectRefLayerId (i, j), 6, "ref_layer_id[i][j]" ); |
---|
| 361 | } |
---|
| 362 | } |
---|
| 363 | } |
---|
| 364 | for( UInt i=1; i<=pcVPS->getNumAddiProLevelSets(); i++) |
---|
| 365 | { |
---|
| 366 | //profile_tier_level |
---|
| 367 | } |
---|
| 368 | for( UInt i=1; i<= pcVPS->getNumAddiLayerOperationPoints(); i++) |
---|
| 369 | { |
---|
| 370 | if(pcVPS->getMaxLayers() == 3) |
---|
| 371 | { |
---|
| 372 | pcVPS->setNumOpLayerIdMinus1((i < pcVPS->getNumAddiLayerOperationPoints() ? 1: 2), (i-1)); |
---|
| 373 | } |
---|
| 374 | else if( i==1 ) |
---|
| 375 | { |
---|
| 376 | assert(pcVPS->getNumAddiLayerOperationPoints()==1); |
---|
| 377 | pcVPS->setNumOpLayerIdMinus1(pcVPS->getMaxLayers()-1, (i-1)); |
---|
| 378 | } |
---|
| 379 | WRITE_UVLC( pcVPS->getNumOpLayerIdMinus1(i-1), "op_num_layer_id_values_minus1[ opIdx ]" ); |
---|
| 380 | for(UInt j = 0; j <= pcVPS->getNumOpLayerIdMinus1(i-1); j++ ) |
---|
| 381 | { |
---|
| 382 | if(pcVPS->getMaxLayers() == 3 && i== 2 && j==1) |
---|
| 383 | pcVPS->setNumOpLayerId (2, i-1, j); |
---|
| 384 | else |
---|
| 385 | pcVPS->setNumOpLayerId (j, i-1, j); |
---|
| 386 | WRITE_UVLC( pcVPS->getNumOpLayerId(i-1, j), "op_layer_id[ opIdx ][ i ]" ); |
---|
| 387 | } |
---|
| 388 | if (pcVPS->getNumAddiProLevelSets()) |
---|
| 389 | { |
---|
| 390 | //profile_level_idx[ i ] |
---|
| 391 | } |
---|
| 392 | } |
---|
| 393 | return; |
---|
| 394 | } |
---|
| 395 | #else |
---|
[77] | 396 | #if VIDYO_VPS_INTEGRATION |
---|
| 397 | Void TEncCavlc::codeVPS( TComVPS* pcVPS ) |
---|
| 398 | { |
---|
[100] | 399 | WRITE_CODE( pcVPS->getMaxTLayers() - 1, 3, "max_temporal_layers_minus1" ); |
---|
[77] | 400 | WRITE_CODE( pcVPS->getMaxLayers() - 1, 5, "max_layers_minus1" ); |
---|
| 401 | WRITE_FLAG( pcVPS->getTemporalNestingFlag() - 1, "temporal_id_nesting_flag" ); |
---|
| 402 | WRITE_UVLC( pcVPS->getVPSId(), "video_parameter_set_id" ); |
---|
| 403 | for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
| 404 | { |
---|
| 405 | WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i), "max_dec_pic_buffering[i]" ); |
---|
| 406 | WRITE_UVLC( pcVPS->getNumReorderPics(i), "num_reorder_pics[i]" ); |
---|
| 407 | WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i), "max_latency_increase[i]" ); |
---|
| 408 | } |
---|
| 409 | |
---|
| 410 | WRITE_CODE( 1, 1, "bit_equal_to_one" ); |
---|
| 411 | |
---|
| 412 | if( pcVPS->getMaxLayers() - 1 > 0 ) |
---|
| 413 | { |
---|
| 414 | WRITE_UVLC( pcVPS->getExtensionType(), "extension_type" ); |
---|
| 415 | |
---|
| 416 | for(UInt i=1; i <= pcVPS->getMaxLayers()-1; i++) |
---|
| 417 | { |
---|
| 418 | WRITE_FLAG( pcVPS->getDependentFlag(i), "dependent_flag[i]" ); |
---|
| 419 | if( pcVPS->getDependentFlag(i) ) |
---|
| 420 | { |
---|
| 421 | WRITE_UVLC( i - pcVPS->getDependentLayer(i) - 1, "delta_reference_layer_id_minus1[i]" ); |
---|
| 422 | if( pcVPS->getExtensionType() == VPS_EXTENSION_TYPE_MULTI_VIEW ) |
---|
| 423 | { |
---|
| 424 | WRITE_UVLC( pcVPS->getViewId(i), "view_id[i]" ); |
---|
| 425 | WRITE_FLAG( pcVPS->getDepthFlag(i), "depth_flag[i]" ); |
---|
| 426 | WRITE_SVLC( pcVPS->getViewOrderIdx(i), "view_order_idx[i]" ); |
---|
| 427 | } |
---|
| 428 | |
---|
| 429 | } |
---|
| 430 | } |
---|
[280] | 431 | #if INTER_VIEW_VECTOR_SCALING_C0115 |
---|
| 432 | WRITE_FLAG( pcVPS->getIVScalingFlag(), "inter_view_vector_scaling_flag" ); |
---|
| 433 | #endif |
---|
[77] | 434 | } |
---|
| 435 | |
---|
| 436 | WRITE_FLAG( 0, "vps_extension_flag" ); |
---|
| 437 | |
---|
| 438 | //future extensions here.. |
---|
| 439 | |
---|
| 440 | return; |
---|
| 441 | } |
---|
| 442 | #endif |
---|
[210] | 443 | #endif |
---|
[280] | 444 | #if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068 |
---|
[56] | 445 | Void TEncCavlc::codeSPS( TComSPS* pcSPS, Bool bIsDepth ) |
---|
[2] | 446 | #else |
---|
[56] | 447 | Void TEncCavlc::codeSPS( TComSPS* pcSPS ) |
---|
[2] | 448 | #endif |
---|
[56] | 449 | { |
---|
| 450 | #if ENC_DEC_TRACE |
---|
| 451 | xTraceSPSHeader (pcSPS); |
---|
[2] | 452 | #endif |
---|
[56] | 453 | WRITE_CODE( pcSPS->getProfileIdc (), 8, "profile_idc" ); |
---|
| 454 | WRITE_CODE( 0, 8, "reserved_zero_8bits" ); |
---|
| 455 | WRITE_CODE( pcSPS->getLevelIdc (), 8, "level_idc" ); |
---|
| 456 | WRITE_UVLC( pcSPS->getSPSId (), "seq_parameter_set_id" ); |
---|
[77] | 457 | #if VIDYO_VPS_INTEGRATION |
---|
| 458 | WRITE_UVLC( pcSPS->getVPSId (), "video_parameter_set_id" ); |
---|
| 459 | #endif |
---|
[56] | 460 | WRITE_UVLC( pcSPS->getChromaFormatIdc (), "chroma_format_idc" ); |
---|
| 461 | WRITE_CODE( pcSPS->getMaxTLayers() - 1, 3, "max_temporal_layers_minus1" ); |
---|
| 462 | WRITE_UVLC( pcSPS->getPicWidthInLumaSamples (), "pic_width_in_luma_samples" ); |
---|
| 463 | WRITE_UVLC( pcSPS->getPicHeightInLumaSamples(), "pic_height_in_luma_samples" ); |
---|
| 464 | WRITE_FLAG( pcSPS->getPicCroppingFlag(), "pic_cropping_flag" ); |
---|
| 465 | if (pcSPS->getPicCroppingFlag()) |
---|
[2] | 466 | { |
---|
[56] | 467 | WRITE_UVLC( pcSPS->getPicCropLeftOffset(), "pic_crop_left_offset" ); |
---|
| 468 | WRITE_UVLC( pcSPS->getPicCropRightOffset(), "pic_crop_right_offset" ); |
---|
| 469 | WRITE_UVLC( pcSPS->getPicCropTopOffset(), "pic_crop_top_offset" ); |
---|
| 470 | WRITE_UVLC( pcSPS->getPicCropBottomOffset(), "pic_crop_bottom_offset" ); |
---|
[2] | 471 | } |
---|
| 472 | |
---|
[56] | 473 | #if FULL_NBIT |
---|
| 474 | WRITE_UVLC( pcSPS->getBitDepth() - 8, "bit_depth_luma_minus8" ); |
---|
[2] | 475 | #else |
---|
[56] | 476 | WRITE_UVLC( pcSPS->getBitIncrement(), "bit_depth_luma_minus8" ); |
---|
[2] | 477 | #endif |
---|
[56] | 478 | #if FULL_NBIT |
---|
| 479 | WRITE_UVLC( pcSPS->getBitDepth() - 8, "bit_depth_chroma_minus8" ); |
---|
| 480 | #else |
---|
| 481 | WRITE_UVLC( pcSPS->getBitIncrement(), "bit_depth_chroma_minus8" ); |
---|
[2] | 482 | #endif |
---|
| 483 | |
---|
[56] | 484 | WRITE_FLAG( pcSPS->getUsePCM() ? 1 : 0, "pcm_enabled_flag"); |
---|
[2] | 485 | |
---|
[56] | 486 | if( pcSPS->getUsePCM() ) |
---|
[2] | 487 | { |
---|
[56] | 488 | WRITE_CODE( pcSPS->getPCMBitDepthLuma() - 1, 4, "pcm_bit_depth_luma_minus1" ); |
---|
| 489 | WRITE_CODE( pcSPS->getPCMBitDepthChroma() - 1, 4, "pcm_bit_depth_chroma_minus1" ); |
---|
[2] | 490 | } |
---|
[56] | 491 | |
---|
| 492 | #if LOSSLESS_CODING |
---|
| 493 | WRITE_FLAG( (pcSPS->getUseLossless ()) ? 1 : 0, "qpprime_y_zero_transquant_bypass_flag" ); |
---|
[2] | 494 | #endif |
---|
[56] | 495 | |
---|
| 496 | WRITE_UVLC( pcSPS->getBitsForPOC()-4, "log2_max_pic_order_cnt_lsb_minus4" ); |
---|
| 497 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
[2] | 498 | { |
---|
[56] | 499 | WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i), "max_dec_pic_buffering[i]" ); |
---|
| 500 | WRITE_UVLC( pcSPS->getNumReorderPics(i), "num_reorder_pics[i]" ); |
---|
| 501 | WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i), "max_latency_increase[i]" ); |
---|
[2] | 502 | } |
---|
[56] | 503 | assert( pcSPS->getMaxCUWidth() == pcSPS->getMaxCUHeight() ); |
---|
| 504 | |
---|
| 505 | UInt MinCUSize = pcSPS->getMaxCUWidth() >> ( pcSPS->getMaxCUDepth()-g_uiAddCUDepth ); |
---|
| 506 | UInt log2MinCUSize = 0; |
---|
| 507 | while(MinCUSize > 1) |
---|
[2] | 508 | { |
---|
[56] | 509 | MinCUSize >>= 1; |
---|
| 510 | log2MinCUSize++; |
---|
[2] | 511 | } |
---|
| 512 | |
---|
[56] | 513 | WRITE_FLAG( pcSPS->getRestrictedRefPicListsFlag(), "restricted_ref_pic_lists_flag" ); |
---|
| 514 | if( pcSPS->getRestrictedRefPicListsFlag() ) |
---|
[2] | 515 | { |
---|
[56] | 516 | WRITE_FLAG( pcSPS->getListsModificationPresentFlag(), "lists_modification_present_flag" ); |
---|
[2] | 517 | } |
---|
[56] | 518 | WRITE_UVLC( log2MinCUSize - 3, "log2_min_coding_block_size_minus3" ); |
---|
| 519 | WRITE_UVLC( pcSPS->getMaxCUDepth()-g_uiAddCUDepth, "log2_diff_max_min_coding_block_size" ); |
---|
| 520 | WRITE_UVLC( pcSPS->getQuadtreeTULog2MinSize() - 2, "log2_min_transform_block_size_minus2" ); |
---|
| 521 | WRITE_UVLC( pcSPS->getQuadtreeTULog2MaxSize() - pcSPS->getQuadtreeTULog2MinSize(), "log2_diff_max_min_transform_block_size" ); |
---|
[2] | 522 | |
---|
[56] | 523 | if(log2MinCUSize == 3) |
---|
[2] | 524 | { |
---|
[56] | 525 | xWriteFlag ( (pcSPS->getDisInter4x4()) ? 1 : 0 ); |
---|
[2] | 526 | } |
---|
| 527 | |
---|
[56] | 528 | if( pcSPS->getUsePCM() ) |
---|
[2] | 529 | { |
---|
[56] | 530 | WRITE_UVLC( pcSPS->getPCMLog2MinSize() - 3, "log2_min_pcm_coding_block_size_minus3" ); |
---|
| 531 | WRITE_UVLC( pcSPS->getPCMLog2MaxSize() - pcSPS->getPCMLog2MinSize(), "log2_diff_max_min_pcm_coding_block_size" ); |
---|
[2] | 532 | } |
---|
[56] | 533 | WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthInter() - 1, "max_transform_hierarchy_depth_inter" ); |
---|
| 534 | WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthIntra() - 1, "max_transform_hierarchy_depth_intra" ); |
---|
| 535 | WRITE_FLAG( pcSPS->getScalingListFlag() ? 1 : 0, "scaling_list_enabled_flag" ); |
---|
| 536 | WRITE_FLAG( pcSPS->getUseLMChroma () ? 1 : 0, "chroma_pred_from_luma_enabled_flag" ); |
---|
| 537 | WRITE_FLAG( pcSPS->getUseDF() ? 1 : 0, "deblocking_filter_in_aps_enabled_flag"); |
---|
| 538 | WRITE_FLAG( pcSPS->getLFCrossSliceBoundaryFlag()?1 : 0, "seq_loop_filter_across_slices_enabled_flag"); |
---|
| 539 | WRITE_FLAG( pcSPS->getUseAMP(), "asymmetric_motion_partitions_enabled_flag" ); |
---|
| 540 | WRITE_FLAG( pcSPS->getUseNSQT(), "non_square_quadtree_enabled_flag" ); |
---|
| 541 | WRITE_FLAG( pcSPS->getUseSAO() ? 1 : 0, "sample_adaptive_offset_enabled_flag"); |
---|
| 542 | WRITE_FLAG( pcSPS->getUseALF () ? 1 : 0, "adaptive_loop_filter_enabled_flag"); |
---|
| 543 | if(pcSPS->getUseALF()) |
---|
[2] | 544 | { |
---|
[56] | 545 | WRITE_FLAG( (pcSPS->getUseALFCoefInSlice()) ? 1 : 0, "alf_coef_in_slice_flag"); |
---|
[2] | 546 | } |
---|
| 547 | |
---|
[56] | 548 | if( pcSPS->getUsePCM() ) |
---|
[2] | 549 | { |
---|
[56] | 550 | WRITE_FLAG( pcSPS->getPCMFilterDisableFlag()?1 : 0, "pcm_loop_filter_disable_flag"); |
---|
[2] | 551 | } |
---|
| 552 | |
---|
[56] | 553 | assert( pcSPS->getMaxTLayers() > 0 ); |
---|
[2] | 554 | |
---|
[56] | 555 | WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0, "temporal_id_nesting_flag" ); |
---|
[2] | 556 | |
---|
[56] | 557 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
| 558 | TComReferencePictureSet* rps; |
---|
[2] | 559 | |
---|
[56] | 560 | WRITE_UVLC(rpsList->getNumberOfReferencePictureSets(), "num_short_term_ref_pic_sets" ); |
---|
| 561 | for(Int i=0; i < rpsList->getNumberOfReferencePictureSets(); i++) |
---|
[2] | 562 | { |
---|
[56] | 563 | rps = rpsList->getReferencePictureSet(i); |
---|
| 564 | codeShortTermRefPicSet(pcSPS,rps); |
---|
| 565 | } |
---|
| 566 | WRITE_FLAG( pcSPS->getLongTermRefsPresent() ? 1 : 0, "long_term_ref_pics_present_flag" ); |
---|
| 567 | // AMVP mode for each depth |
---|
| 568 | for (Int i = 0; i < pcSPS->getMaxCUDepth(); i++) |
---|
[2] | 569 | { |
---|
[56] | 570 | xWriteFlag( pcSPS->getAMVPMode(i) ? 1 : 0); |
---|
[2] | 571 | } |
---|
| 572 | |
---|
[56] | 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"); |
---|
| 584 | |
---|
| 585 | if(tilesOrEntropyCodingSyncIdc == 1) |
---|
[2] | 586 | { |
---|
[56] | 587 | WRITE_UVLC( pcSPS->getNumColumnsMinus1(), "num_tile_columns_minus1" ); |
---|
| 588 | WRITE_UVLC( pcSPS->getNumRowsMinus1(), "num_tile_rows_minus1" ); |
---|
| 589 | WRITE_FLAG( pcSPS->getUniformSpacingIdr(), "uniform_spacing_flag" ); |
---|
[2] | 590 | |
---|
[56] | 591 | if( pcSPS->getUniformSpacingIdr()==0 ) |
---|
[2] | 592 | { |
---|
[56] | 593 | for(UInt i=0; i<pcSPS->getNumColumnsMinus1(); i++) |
---|
[2] | 594 | { |
---|
[56] | 595 | WRITE_UVLC( pcSPS->getColumnWidth(i), "column_width" ); |
---|
[2] | 596 | } |
---|
[56] | 597 | for(UInt i=0; i<pcSPS->getNumRowsMinus1(); i++) |
---|
[2] | 598 | { |
---|
[56] | 599 | WRITE_UVLC( pcSPS->getRowHeight(i), "row_height" ); |
---|
[2] | 600 | } |
---|
| 601 | } |
---|
[56] | 602 | |
---|
| 603 | if( pcSPS->getNumColumnsMinus1() !=0 || pcSPS->getNumRowsMinus1() != 0) |
---|
[2] | 604 | { |
---|
[56] | 605 | WRITE_FLAG( pcSPS->getLFCrossTileBoundaryFlag()?1 : 0, "loop_filter_across_tile_flag"); |
---|
[2] | 606 | } |
---|
| 607 | } |
---|
[56] | 608 | WRITE_FLAG( 1, "sps_extension_flag" ); |
---|
[210] | 609 | #if !QC_MVHEVC_B0046 |
---|
[56] | 610 | WRITE_FLAG( (pcSPS->getNumberOfUsableInterViewRefs() > 0) ? 1 : 0, "interview_refs_present_flag" ); |
---|
| 611 | if( pcSPS->getNumberOfUsableInterViewRefs() > 0 ) |
---|
[2] | 612 | { |
---|
[56] | 613 | WRITE_UVLC( pcSPS->getNumberOfUsableInterViewRefs() - 1, "num_usable_interview_refs_minus1" ); |
---|
| 614 | |
---|
| 615 | Int prev = 0; |
---|
| 616 | for( Int j = 0 ; j < pcSPS->getNumberOfUsableInterViewRefs(); j++ ) |
---|
| 617 | { |
---|
| 618 | WRITE_UVLC( prev - pcSPS->getUsableInterViewRef( j ) - 1, "delta_usable_interview_ref_minus1" ); |
---|
| 619 | prev = pcSPS->getUsableInterViewRef( j ); |
---|
| 620 | } |
---|
[2] | 621 | } |
---|
| 622 | |
---|
[56] | 623 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
| 624 | WRITE_FLAG( pcSPS->getUseDMM(), "enable_dmm_flag" ); |
---|
[2] | 625 | #endif |
---|
| 626 | |
---|
[56] | 627 | #if HHI_MPI |
---|
| 628 | if( bIsDepth ) |
---|
[2] | 629 | { |
---|
[56] | 630 | WRITE_FLAG( pcSPS->getUseMVI() ? 1 : 0, "use_mvi_flag" ); |
---|
[2] | 631 | } |
---|
| 632 | #endif |
---|
| 633 | |
---|
[189] | 634 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
| 635 | if( bIsDepth ) |
---|
| 636 | { |
---|
| 637 | WRITE_FLAG( pcSPS->getUseQTLPC() ? 1 : 0, "use_qtlpc_flag"); |
---|
| 638 | } |
---|
| 639 | #endif |
---|
| 640 | |
---|
| 641 | #if RWTH_SDC_DLT_B0036 |
---|
| 642 | if( bIsDepth ) |
---|
| 643 | { |
---|
| 644 | WRITE_FLAG( pcSPS->getUseDLT() ? 1 : 0, "use_dlt_flag" ); |
---|
| 645 | if( pcSPS->getUseDLT() ) |
---|
| 646 | { |
---|
| 647 | // code mapping |
---|
| 648 | xWriteUvlc ( pcSPS->getNumDepthValues() ); |
---|
| 649 | for(UInt i=0; i<pcSPS->getNumDepthValues(); i++) |
---|
| 650 | { |
---|
| 651 | xWriteUvlc( pcSPS->idx2DepthValue(i) ); |
---|
| 652 | } |
---|
| 653 | } |
---|
| 654 | } |
---|
| 655 | #endif |
---|
| 656 | |
---|
[56] | 657 | if( pcSPS->getViewId() || pcSPS->isDepth() ) |
---|
[2] | 658 | { |
---|
[56] | 659 | WRITE_FLAG( 0, "base_view_flag" ); |
---|
| 660 | if( pcSPS->isDepth() ) |
---|
[2] | 661 | { |
---|
[56] | 662 | WRITE_FLAG( 1, "depth_flag" ); |
---|
| 663 | WRITE_UVLC( pcSPS->getViewId(), "view_id" ); |
---|
| 664 | WRITE_SVLC( pcSPS->getViewOrderIdx(), "view_order_idx" ); |
---|
[2] | 665 | } |
---|
| 666 | else |
---|
| 667 | { |
---|
[56] | 668 | WRITE_FLAG( 0, "depth_flag" ); |
---|
| 669 | WRITE_UVLC( pcSPS->getViewId() - 1, "view_id_minus1" ); |
---|
| 670 | WRITE_SVLC( pcSPS->getViewOrderIdx(), "view_order_idx" ); |
---|
| 671 | WRITE_UVLC( pcSPS->getCamParPrecision(), "camera_parameter_precision" ); |
---|
| 672 | WRITE_FLAG( pcSPS->hasCamParInSliceHeader() ? 1 : 0, "camera_parameter_in_slice_header" ); |
---|
| 673 | if( !pcSPS->hasCamParInSliceHeader() ) |
---|
| 674 | { |
---|
| 675 | for( UInt uiId = 0; uiId < pcSPS->getViewId(); uiId++ ) |
---|
| 676 | { |
---|
| 677 | WRITE_SVLC( pcSPS->getCodedScale ()[ uiId ], "coded_scale" ); |
---|
| 678 | WRITE_SVLC( pcSPS->getCodedOffset ()[ uiId ], "coded_offset" ); |
---|
| 679 | WRITE_SVLC( pcSPS->getInvCodedScale ()[ uiId ] + pcSPS->getCodedScale ()[ uiId ], "inverse_coded_scale_plus_coded_scale" ); |
---|
| 680 | WRITE_SVLC( pcSPS->getInvCodedOffset()[ uiId ] + pcSPS->getCodedOffset()[ uiId ], "inverse_coded_offset_plus_coded_offset" ); |
---|
| 681 | } |
---|
[2] | 682 | } |
---|
[56] | 683 | #if DEPTH_MAP_GENERATION |
---|
| 684 | WRITE_UVLC( pcSPS->getPredDepthMapGeneration(), "Pdm_generation" ); |
---|
| 685 | if( pcSPS->getPredDepthMapGeneration() ) |
---|
[2] | 686 | { |
---|
[56] | 687 | WRITE_UVLC( pcSPS->getPdmPrecision(), "Pdm_precision" ); |
---|
| 688 | for( UInt uiId = 0; uiId < pcSPS->getViewId(); uiId++ ) |
---|
| 689 | { |
---|
| 690 | WRITE_SVLC( pcSPS->getPdmScaleNomDelta()[ uiId ], "Pdm_scale_nom_delta" ); |
---|
| 691 | WRITE_SVLC( pcSPS->getPdmOffset ()[ uiId ], "Pdm_offset" ); |
---|
| 692 | } |
---|
[292] | 693 | #if H3D_IVMP |
---|
[56] | 694 | WRITE_UVLC( pcSPS->getMultiviewMvPredMode(), "multi_view_mv_pred_mode" ); |
---|
| 695 | #endif |
---|
[295] | 696 | #if H3D_IVRP |
---|
[56] | 697 | WRITE_FLAG ( pcSPS->getMultiviewResPredMode(), "multi_view_residual_pred_mode" ); |
---|
| 698 | #endif |
---|
[2] | 699 | } |
---|
[56] | 700 | #endif |
---|
[2] | 701 | } |
---|
| 702 | } |
---|
[56] | 703 | else |
---|
[2] | 704 | { |
---|
[56] | 705 | WRITE_FLAG( 1, "base_view_flag" ); |
---|
[2] | 706 | } |
---|
[56] | 707 | WRITE_FLAG( 0, "sps_extension2_flag" ); |
---|
[210] | 708 | #endif |
---|
[56] | 709 | } |
---|
[2] | 710 | |
---|
[56] | 711 | Void TEncCavlc::writeTileMarker( UInt uiTileIdx, UInt uiBitsUsed ) |
---|
| 712 | { |
---|
| 713 | xWriteCode( uiTileIdx, uiBitsUsed ); |
---|
[2] | 714 | } |
---|
| 715 | |
---|
[56] | 716 | Void TEncCavlc::codeSliceHeader ( TComSlice* pcSlice ) |
---|
[2] | 717 | { |
---|
[56] | 718 | #if ENC_DEC_TRACE |
---|
| 719 | xTraceSliceHeader (pcSlice); |
---|
[2] | 720 | #endif |
---|
| 721 | |
---|
[56] | 722 | // if( nal_ref_idc != 0 ) |
---|
| 723 | // dec_ref_pic_marking( ) |
---|
| 724 | // if( entropy_coding_mode_flag && slice_type != I) |
---|
| 725 | // cabac_init_idc |
---|
| 726 | // first_slice_in_pic_flag |
---|
| 727 | // if( first_slice_in_pic_flag == 0 ) |
---|
| 728 | // slice_address |
---|
| 729 | //calculate number of bits required for slice address |
---|
| 730 | Int maxAddrOuter = pcSlice->getPic()->getNumCUsInFrame(); |
---|
| 731 | Int reqBitsOuter = 0; |
---|
| 732 | while(maxAddrOuter>(1<<reqBitsOuter)) |
---|
[2] | 733 | { |
---|
[56] | 734 | reqBitsOuter++; |
---|
[2] | 735 | } |
---|
[56] | 736 | Int maxAddrInner = pcSlice->getPic()->getNumPartInCU()>>(2); |
---|
| 737 | maxAddrInner = (1<<(pcSlice->getPPS()->getSliceGranularity()<<1)); |
---|
| 738 | Int reqBitsInner = 0; |
---|
| 739 | |
---|
| 740 | while(maxAddrInner>(1<<reqBitsInner)) |
---|
[2] | 741 | { |
---|
[56] | 742 | reqBitsInner++; |
---|
[2] | 743 | } |
---|
[56] | 744 | Int lCUAddress; |
---|
| 745 | Int innerAddress; |
---|
| 746 | if (pcSlice->isNextSlice()) |
---|
[2] | 747 | { |
---|
[56] | 748 | // Calculate slice address |
---|
| 749 | lCUAddress = (pcSlice->getSliceCurStartCUAddr()/pcSlice->getPic()->getNumPartInCU()); |
---|
| 750 | innerAddress = (pcSlice->getSliceCurStartCUAddr()%(pcSlice->getPic()->getNumPartInCU()))>>((pcSlice->getSPS()->getMaxCUDepth()-pcSlice->getPPS()->getSliceGranularity())<<1); |
---|
[2] | 751 | } |
---|
| 752 | else |
---|
| 753 | { |
---|
[56] | 754 | // Calculate slice address |
---|
| 755 | lCUAddress = (pcSlice->getEntropySliceCurStartCUAddr()/pcSlice->getPic()->getNumPartInCU()); |
---|
| 756 | innerAddress = (pcSlice->getEntropySliceCurStartCUAddr()%(pcSlice->getPic()->getNumPartInCU()))>>((pcSlice->getSPS()->getMaxCUDepth()-pcSlice->getPPS()->getSliceGranularity())<<1); |
---|
| 757 | |
---|
[2] | 758 | } |
---|
[56] | 759 | //write slice address |
---|
| 760 | Int address = (pcSlice->getPic()->getPicSym()->getCUOrderMap(lCUAddress) << reqBitsInner) + innerAddress; |
---|
| 761 | WRITE_FLAG( address==0, "first_slice_in_pic_flag" ); |
---|
[189] | 762 | |
---|
| 763 | #if LGE_ILLUCOMP_B0045 |
---|
| 764 | // IC flag is on only first_slice_in_pic |
---|
| 765 | if (address==0) |
---|
| 766 | { |
---|
[287] | 767 | if( pcSlice->getSPS()->getViewId() |
---|
| 768 | #if !LGE_ILLUCOMP_DEPTH_C0046 |
---|
| 769 | && !pcSlice->getIsDepth() |
---|
| 770 | #endif |
---|
| 771 | ) |
---|
[189] | 772 | { |
---|
| 773 | WRITE_FLAG( pcSlice->getApplyIC() ? 1 : 0, "applying IC flag" ); |
---|
| 774 | } |
---|
| 775 | } |
---|
| 776 | #endif |
---|
| 777 | |
---|
[56] | 778 | if(address>0) |
---|
[2] | 779 | { |
---|
[56] | 780 | WRITE_CODE( address, reqBitsOuter+reqBitsInner, "slice_address" ); |
---|
[2] | 781 | } |
---|
| 782 | |
---|
[56] | 783 | WRITE_UVLC( pcSlice->getSliceType(), "slice_type" ); |
---|
| 784 | Bool bEntropySlice = (!pcSlice->isNextSlice()); |
---|
| 785 | WRITE_FLAG( bEntropySlice ? 1 : 0, "lightweight_slice_flag" ); |
---|
| 786 | |
---|
| 787 | if (!bEntropySlice) |
---|
[2] | 788 | { |
---|
[210] | 789 | #if QC_MVHEVC_B0046 |
---|
| 790 | WRITE_UVLC( 0, "pic_parameter_set_id" ); |
---|
| 791 | #else |
---|
[56] | 792 | WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "pic_parameter_set_id" ); |
---|
[210] | 793 | #endif |
---|
[56] | 794 | if( pcSlice->getPPS()->getOutputFlagPresentFlag() ) |
---|
[2] | 795 | { |
---|
[56] | 796 | WRITE_FLAG( pcSlice->getPicOutputFlag() ? 1 : 0, "pic_output_flag" ); |
---|
[2] | 797 | } |
---|
[210] | 798 | #if QC_REM_IDV_B0046 |
---|
| 799 | if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_IDR && pcSlice->getViewId() == 0) |
---|
| 800 | #else |
---|
[56] | 801 | if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_IDR) |
---|
[210] | 802 | #endif |
---|
[2] | 803 | { |
---|
[56] | 804 | WRITE_UVLC( 0, "idr_pic_id" ); |
---|
| 805 | WRITE_FLAG( 0, "no_output_of_prior_pics_flag" ); |
---|
[2] | 806 | } |
---|
| 807 | else |
---|
| 808 | { |
---|
[56] | 809 | WRITE_CODE( (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC()))%(1<<pcSlice->getSPS()->getBitsForPOC()), pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb"); |
---|
[210] | 810 | #if QC_REM_IDV_B0046 |
---|
| 811 | if( pcSlice->getPOC() == 0 && !(pcSlice->getSPS()->getViewId() && (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA))) |
---|
| 812 | #else |
---|
[77] | 813 | if( pcSlice->getPOC() == 0 && pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDV ) |
---|
[210] | 814 | #endif |
---|
[77] | 815 | { |
---|
| 816 | TComReferencePictureSet* rps = pcSlice->getRPS(); |
---|
| 817 | if(pcSlice->getRPSidx() < 0) |
---|
| 818 | { |
---|
| 819 | WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag"); |
---|
| 820 | codeShortTermRefPicSet(pcSlice->getSPS(), rps); |
---|
| 821 | } |
---|
| 822 | else |
---|
| 823 | { |
---|
| 824 | WRITE_FLAG( 1, "short_term_ref_pic_set_sps_flag"); |
---|
| 825 | WRITE_UVLC( pcSlice->getRPSidx(), "short_term_ref_pic_set_idx" ); |
---|
| 826 | } |
---|
| 827 | if(pcSlice->getSPS()->getLongTermRefsPresent()) |
---|
| 828 | { |
---|
| 829 | WRITE_UVLC( rps->getNumberOfLongtermPictures(), "num_long_term_pics"); |
---|
| 830 | Int maxPocLsb = 1<<pcSlice->getSPS()->getBitsForPOC(); |
---|
| 831 | Int prev = 0; |
---|
| 832 | Int prevDeltaPocLt=0; |
---|
| 833 | Int currDeltaPocLt=0; |
---|
| 834 | for(Int i=rps->getNumberOfPictures()-1 ; i > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; i--) |
---|
| 835 | { |
---|
| 836 | WRITE_UVLC((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb, "delta_poc_lsb_lt"); |
---|
| 837 | |
---|
| 838 | currDeltaPocLt=((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb)+prevDeltaPocLt; |
---|
[2] | 839 | |
---|
[77] | 840 | Int deltaMsbCycle=0; |
---|
| 841 | if( (i==(rps->getNumberOfPictures()-1)) ) |
---|
| 842 | { |
---|
| 843 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 844 | } |
---|
| 845 | else if( prevDeltaPocLt!=currDeltaPocLt ) |
---|
| 846 | { |
---|
| 847 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 848 | if( ((prevDeltaPocLt==maxPocLsb-1) && (currDeltaPocLt==maxPocLsb+1)) || ((prevDeltaPocLt==maxPocLsb-2) && (currDeltaPocLt==maxPocLsb))) |
---|
| 849 | { |
---|
| 850 | deltaMsbCycle=deltaMsbCycle-1; |
---|
| 851 | } |
---|
| 852 | } |
---|
| 853 | else |
---|
| 854 | { |
---|
| 855 | deltaMsbCycle=((rps->getDeltaPOC(i+1)-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 856 | } |
---|
| 857 | |
---|
| 858 | if(deltaMsbCycle>=0) |
---|
| 859 | { |
---|
| 860 | WRITE_FLAG( 1, "delta_poc_msb_present_flag"); |
---|
| 861 | WRITE_UVLC(deltaMsbCycle, "delta_poc_msb_cycle_lt_minus1"); |
---|
| 862 | } |
---|
| 863 | else |
---|
| 864 | { |
---|
| 865 | WRITE_FLAG( 0, "delta_poc_msb_present_flag"); |
---|
| 866 | } |
---|
| 867 | prevDeltaPocLt=currDeltaPocLt; |
---|
| 868 | prev = rps->getDeltaPOC(i); |
---|
| 869 | WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag"); |
---|
| 870 | } |
---|
| 871 | } |
---|
| 872 | } |
---|
| 873 | if( pcSlice->getPOC() != 0 ) |
---|
[2] | 874 | { |
---|
[56] | 875 | TComReferencePictureSet* rps = pcSlice->getRPS(); |
---|
| 876 | if(pcSlice->getRPSidx() < 0) |
---|
| 877 | { |
---|
| 878 | WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag"); |
---|
| 879 | codeShortTermRefPicSet(pcSlice->getSPS(), rps); |
---|
| 880 | } |
---|
| 881 | else |
---|
[2] | 882 | { |
---|
[56] | 883 | WRITE_FLAG( 1, "short_term_ref_pic_set_sps_flag"); |
---|
| 884 | WRITE_UVLC( pcSlice->getRPSidx(), "short_term_ref_pic_set_idx" ); |
---|
[2] | 885 | } |
---|
[56] | 886 | if(pcSlice->getSPS()->getLongTermRefsPresent()) |
---|
[2] | 887 | { |
---|
[56] | 888 | WRITE_UVLC( rps->getNumberOfLongtermPictures(), "num_long_term_pics"); |
---|
| 889 | Int maxPocLsb = 1<<pcSlice->getSPS()->getBitsForPOC(); |
---|
| 890 | Int prev = 0; |
---|
| 891 | Int prevDeltaPocLt=0; |
---|
| 892 | Int currDeltaPocLt=0; |
---|
| 893 | for(Int i=rps->getNumberOfPictures()-1 ; i > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; i--) |
---|
| 894 | { |
---|
| 895 | WRITE_UVLC((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb, "delta_poc_lsb_lt"); |
---|
| 896 | |
---|
| 897 | currDeltaPocLt=((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb)+prevDeltaPocLt; |
---|
| 898 | |
---|
| 899 | Int deltaMsbCycle=0; |
---|
| 900 | if( (i==(rps->getNumberOfPictures()-1)) ) |
---|
| 901 | { |
---|
| 902 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 903 | } |
---|
| 904 | else if( prevDeltaPocLt!=currDeltaPocLt ) |
---|
| 905 | { |
---|
| 906 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 907 | if( ((prevDeltaPocLt==maxPocLsb-1) && (currDeltaPocLt==maxPocLsb+1)) || ((prevDeltaPocLt==maxPocLsb-2) && (currDeltaPocLt==maxPocLsb))) |
---|
| 908 | { |
---|
| 909 | deltaMsbCycle=deltaMsbCycle-1; |
---|
| 910 | } |
---|
| 911 | } |
---|
| 912 | else |
---|
| 913 | { |
---|
| 914 | deltaMsbCycle=((rps->getDeltaPOC(i+1)-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
| 915 | } |
---|
| 916 | |
---|
| 917 | if(deltaMsbCycle>=0) |
---|
| 918 | { |
---|
| 919 | WRITE_FLAG( 1, "delta_poc_msb_present_flag"); |
---|
| 920 | WRITE_UVLC(deltaMsbCycle, "delta_poc_msb_cycle_lt_minus1"); |
---|
| 921 | } |
---|
| 922 | else |
---|
| 923 | { |
---|
| 924 | WRITE_FLAG( 0, "delta_poc_msb_present_flag"); |
---|
| 925 | } |
---|
| 926 | prevDeltaPocLt=currDeltaPocLt; |
---|
| 927 | prev = rps->getDeltaPOC(i); |
---|
| 928 | WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag"); |
---|
| 929 | } |
---|
[2] | 930 | } |
---|
| 931 | } |
---|
| 932 | } |
---|
[56] | 933 | |
---|
| 934 | if(pcSlice->getSPS()->getUseSAO() || pcSlice->getSPS()->getUseALF()|| pcSlice->getSPS()->getScalingListFlag() || pcSlice->getSPS()->getUseDF()) |
---|
[2] | 935 | { |
---|
[56] | 936 | if (pcSlice->getSPS()->getUseALF()) |
---|
[2] | 937 | { |
---|
[56] | 938 | WRITE_FLAG( pcSlice->getAlfEnabledFlag(), "ALF on/off flag in slice header" ); |
---|
[2] | 939 | } |
---|
[56] | 940 | if (pcSlice->getSPS()->getUseSAO()) |
---|
[2] | 941 | { |
---|
[56] | 942 | WRITE_FLAG( pcSlice->getSaoInterleavingFlag(), "SAO interleaving flag" ); |
---|
| 943 | assert (pcSlice->getSaoEnabledFlag() == pcSlice->getAPS()->getSaoEnabled()); |
---|
| 944 | WRITE_FLAG( pcSlice->getSaoEnabledFlag(), "SAO on/off flag in slice header" ); |
---|
| 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 | } |
---|
[2] | 950 | } |
---|
[56] | 951 | WRITE_UVLC( pcSlice->getAPS()->getAPSID(), "aps_id"); |
---|
[2] | 952 | } |
---|
[56] | 953 | |
---|
| 954 | // we always set num_ref_idx_active_override_flag equal to one. this might be done in a more intelligent way |
---|
| 955 | if (!pcSlice->isIntra()) |
---|
| 956 | { |
---|
| 957 | WRITE_FLAG( 1 , "num_ref_idx_active_override_flag"); |
---|
| 958 | WRITE_CODE( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - 1, 3, "num_ref_idx_l0_active_minus1" ); |
---|
| 959 | } |
---|
[2] | 960 | else |
---|
| 961 | { |
---|
[56] | 962 | pcSlice->setNumRefIdx(REF_PIC_LIST_0, 0); |
---|
[2] | 963 | } |
---|
[56] | 964 | if (pcSlice->isInterB()) |
---|
[2] | 965 | { |
---|
[56] | 966 | WRITE_CODE( pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - 1, 3, "num_ref_idx_l1_active_minus1" ); |
---|
[2] | 967 | } |
---|
[56] | 968 | else |
---|
[2] | 969 | { |
---|
[56] | 970 | pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
[2] | 971 | } |
---|
[56] | 972 | if( pcSlice->getSPS()->getListsModificationPresentFlag() ) |
---|
| 973 | { |
---|
| 974 | TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); |
---|
| 975 | if( !pcSlice->isIntra() ) |
---|
[2] | 976 | { |
---|
[56] | 977 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0() ? 1 : 0, "ref_pic_list_modification_flag_l0" ); |
---|
| 978 | if (pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0()) |
---|
[2] | 979 | { |
---|
[56] | 980 | Int NumPocTotalCurr = pcSlice->getNumPocTotalCurrMvc(); |
---|
| 981 | if (NumPocTotalCurr > 1) |
---|
[2] | 982 | { |
---|
[56] | 983 | Int length = 1; |
---|
| 984 | NumPocTotalCurr --; |
---|
| 985 | while ( NumPocTotalCurr >>= 1) |
---|
[2] | 986 | { |
---|
[56] | 987 | length ++; |
---|
[2] | 988 | } |
---|
[56] | 989 | for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_0 ); i++) |
---|
[2] | 990 | { |
---|
[56] | 991 | WRITE_CODE( refPicListModification->getRefPicSetIdxL0(i), length, "list_entry_l0"); |
---|
[2] | 992 | } |
---|
| 993 | } |
---|
| 994 | } |
---|
[56] | 995 | } |
---|
| 996 | if(pcSlice->isInterB()) |
---|
| 997 | { |
---|
| 998 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1() ? 1 : 0, "ref_pic_list_modification_flag_l1" ); |
---|
| 999 | if (pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1()) |
---|
[2] | 1000 | { |
---|
[56] | 1001 | Int NumPocTotalCurr = pcSlice->getNumPocTotalCurrMvc(); |
---|
| 1002 | if ( NumPocTotalCurr > 1 ) |
---|
[2] | 1003 | { |
---|
[56] | 1004 | Int length = 1; |
---|
| 1005 | NumPocTotalCurr --; |
---|
| 1006 | while ( NumPocTotalCurr >>= 1) |
---|
[2] | 1007 | { |
---|
[56] | 1008 | length ++; |
---|
[2] | 1009 | } |
---|
[56] | 1010 | for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_1 ); i++) |
---|
[2] | 1011 | { |
---|
[56] | 1012 | WRITE_CODE( refPicListModification->getRefPicSetIdxL1(i), length, "list_entry_l1"); |
---|
[2] | 1013 | } |
---|
| 1014 | } |
---|
| 1015 | } |
---|
| 1016 | } |
---|
[56] | 1017 | } |
---|
| 1018 | } |
---|
| 1019 | // ref_pic_list_combination( ) |
---|
| 1020 | // maybe move to own function? |
---|
| 1021 | if (pcSlice->isInterB()) |
---|
| 1022 | { |
---|
| 1023 | WRITE_FLAG(pcSlice->getRefPicListCombinationFlag() ? 1 : 0, "ref_pic_list_combination_flag" ); |
---|
| 1024 | if(pcSlice->getRefPicListCombinationFlag()) |
---|
| 1025 | { |
---|
| 1026 | WRITE_UVLC( pcSlice->getNumRefIdx(REF_PIC_LIST_C) - 1, "num_ref_idx lc_active_minus1"); |
---|
| 1027 | |
---|
| 1028 | if( pcSlice->getSPS()->getListsModificationPresentFlag() ) |
---|
[2] | 1029 | { |
---|
[56] | 1030 | WRITE_FLAG( pcSlice->getRefPicListModificationFlagLC() ? 1 : 0, "ref_pic_list_modification_flag_lc" ); |
---|
| 1031 | if(pcSlice->getRefPicListModificationFlagLC()) |
---|
[2] | 1032 | { |
---|
[56] | 1033 | for (UInt i=0;i<pcSlice->getNumRefIdx(REF_PIC_LIST_C);i++) |
---|
| 1034 | { |
---|
| 1035 | WRITE_FLAG( pcSlice->getListIdFromIdxOfLC(i), "pic_from_list_0_flag" ); |
---|
| 1036 | 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 ) ) |
---|
| 1037 | { |
---|
| 1038 | WRITE_UVLC( pcSlice->getRefIdxFromIdxOfLC(i), "ref_idx_list_curr" ); |
---|
| 1039 | } |
---|
| 1040 | } |
---|
[2] | 1041 | } |
---|
| 1042 | } |
---|
| 1043 | } |
---|
| 1044 | } |
---|
[56] | 1045 | |
---|
| 1046 | if (pcSlice->isInterB()) |
---|
[2] | 1047 | { |
---|
[56] | 1048 | WRITE_FLAG( pcSlice->getMvdL1ZeroFlag() ? 1 : 0, "mvd_l1_zero_flag"); |
---|
[2] | 1049 | } |
---|
| 1050 | |
---|
[56] | 1051 | if(pcSlice->getPPS()->getEntropyCodingMode() && !pcSlice->isIntra()) |
---|
[2] | 1052 | { |
---|
[56] | 1053 | #if CABAC_INIT_FLAG |
---|
| 1054 | if (!pcSlice->isIntra() && pcSlice->getPPS()->getCabacInitPresentFlag()) |
---|
[2] | 1055 | { |
---|
[56] | 1056 | SliceType sliceType = pcSlice->getSliceType(); |
---|
| 1057 | Int encCABACTableIdx = pcSlice->getPPS()->getEncCABACTableIdx(); |
---|
| 1058 | Bool encCabacInitFlag = (sliceType!=encCABACTableIdx && encCABACTableIdx!=0) ? true : false; |
---|
| 1059 | pcSlice->setCabacInitFlag( encCabacInitFlag ); |
---|
| 1060 | WRITE_FLAG( encCabacInitFlag?1:0, "cabac_init_flag" ); |
---|
[2] | 1061 | } |
---|
| 1062 | #else |
---|
[56] | 1063 | WRITE_UVLC(pcSlice->getCABACinitIDC(), "cabac_init_idc"); |
---|
[2] | 1064 | #endif |
---|
| 1065 | } |
---|
| 1066 | |
---|
[56] | 1067 | // if( !lightweight_slice_flag ) { |
---|
| 1068 | if (!bEntropySlice) |
---|
[2] | 1069 | { |
---|
[56] | 1070 | Int iCode = pcSlice->getSliceQp() - ( pcSlice->getPPS()->getPicInitQPMinus26() + 26 ); |
---|
| 1071 | WRITE_SVLC( iCode, "slice_qp_delta" ); |
---|
| 1072 | if (pcSlice->getPPS()->getDeblockingFilterControlPresent()) |
---|
[2] | 1073 | { |
---|
[56] | 1074 | if ( pcSlice->getSPS()->getUseDF() ) |
---|
[2] | 1075 | { |
---|
[56] | 1076 | WRITE_FLAG(pcSlice->getInheritDblParamFromAPS(), "inherit_dbl_param_from_APS_flag"); |
---|
[2] | 1077 | } |
---|
[56] | 1078 | if (!pcSlice->getInheritDblParamFromAPS()) |
---|
[2] | 1079 | { |
---|
[56] | 1080 | WRITE_FLAG(pcSlice->getLoopFilterDisable(), "loop_filter_disable"); // should be an IDC |
---|
| 1081 | if(!pcSlice->getLoopFilterDisable()) |
---|
| 1082 | { |
---|
| 1083 | WRITE_SVLC (pcSlice->getLoopFilterBetaOffset(), "beta_offset_div2"); |
---|
| 1084 | WRITE_SVLC (pcSlice->getLoopFilterTcOffset(), "tc_offset_div2"); |
---|
| 1085 | } |
---|
[2] | 1086 | } |
---|
[56] | 1087 | } |
---|
| 1088 | if ( pcSlice->getSliceType() == B_SLICE ) |
---|
| 1089 | { |
---|
| 1090 | WRITE_FLAG( pcSlice->getColDir(), "collocated_from_l0_flag" ); |
---|
| 1091 | } |
---|
[2] | 1092 | |
---|
[56] | 1093 | #if COLLOCATED_REF_IDX |
---|
| 1094 | if ( pcSlice->getSliceType() != I_SLICE && |
---|
| 1095 | ((pcSlice->getColDir()==0 && pcSlice->getNumRefIdx(REF_PIC_LIST_0)>1)|| |
---|
| 1096 | (pcSlice->getColDir()==1 && pcSlice->getNumRefIdx(REF_PIC_LIST_1)>1))) |
---|
| 1097 | { |
---|
| 1098 | WRITE_UVLC( pcSlice->getColRefIdx(), "collocated_ref_idx" ); |
---|
[2] | 1099 | } |
---|
[56] | 1100 | #endif |
---|
| 1101 | |
---|
| 1102 | if ( (pcSlice->getPPS()->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pcSlice->getPPS()->getWPBiPredIdc()==1 && pcSlice->getSliceType()==B_SLICE) ) |
---|
[2] | 1103 | { |
---|
[56] | 1104 | xCodePredWeightTable( pcSlice ); |
---|
[2] | 1105 | } |
---|
| 1106 | } |
---|
| 1107 | |
---|
[56] | 1108 | // !!!! sytnax elements not in the WD !!!! |
---|
| 1109 | if (!bEntropySlice) |
---|
[2] | 1110 | { |
---|
[56] | 1111 | if( pcSlice->getSPS()->hasCamParInSliceHeader() ) |
---|
| 1112 | { |
---|
| 1113 | for( UInt uiId = 0; uiId < pcSlice->getSPS()->getViewId(); uiId++ ) |
---|
| 1114 | { |
---|
| 1115 | WRITE_SVLC( pcSlice->getCodedScale ()[ uiId ], "coded_scale" ); |
---|
| 1116 | WRITE_SVLC( pcSlice->getCodedOffset ()[ uiId ], "coded_offset" ); |
---|
| 1117 | WRITE_SVLC( pcSlice->getInvCodedScale ()[ uiId ] + pcSlice->getCodedScale ()[ uiId ], "inverse_coded_scale_plus_coded_scale" ); |
---|
| 1118 | WRITE_SVLC( pcSlice->getInvCodedOffset()[ uiId ] + pcSlice->getCodedOffset()[ uiId ], "inverse_coded_offset_plus_coded_offset" ); |
---|
| 1119 | } |
---|
| 1120 | } |
---|
[2] | 1121 | } |
---|
[56] | 1122 | |
---|
[292] | 1123 | #if ( HHI_MPI || H3D_IVMP ) |
---|
| 1124 | #if ( HHI_MPI && H3D_IVMP ) |
---|
[56] | 1125 | const int iExtraMergeCandidates = ( pcSlice->getSPS()->getUseMVI() || pcSlice->getSPS()->getMultiviewMvPredMode() ) ? 1 : 0; |
---|
| 1126 | #elif HHI_MPI |
---|
| 1127 | const int iExtraMergeCandidates = pcSlice->getSPS()->getUseMVI() ? 1 : 0; |
---|
[280] | 1128 | #elif MTK_DEPTH_MERGE_TEXTURE_CANDIDATE_C0137 |
---|
| 1129 | const int iExtraMergeCandidates = ( pcSlice->getIsDepth() || pcSlice->getSPS()->getMultiviewMvPredMode() ) ? 1 : 0; |
---|
[56] | 1130 | #else |
---|
| 1131 | const int iExtraMergeCandidates = pcSlice->getSPS()->getMultiviewMvPredMode() ? 1 : 0; |
---|
| 1132 | #endif |
---|
| 1133 | assert(pcSlice->getMaxNumMergeCand()<=(MRG_MAX_NUM_CANDS_SIGNALED+iExtraMergeCandidates)); |
---|
| 1134 | assert(MRG_MAX_NUM_CANDS_SIGNALED<=MRG_MAX_NUM_CANDS); |
---|
| 1135 | WRITE_UVLC(MRG_MAX_NUM_CANDS + iExtraMergeCandidates - pcSlice->getMaxNumMergeCand(), "maxNumMergeCand"); |
---|
[2] | 1136 | #else |
---|
[56] | 1137 | assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS_SIGNALED); |
---|
| 1138 | assert(MRG_MAX_NUM_CANDS_SIGNALED<=MRG_MAX_NUM_CANDS); |
---|
| 1139 | WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSlice->getMaxNumMergeCand(), "maxNumMergeCand"); |
---|
[2] | 1140 | #endif |
---|
| 1141 | } |
---|
| 1142 | |
---|
| 1143 | |
---|
[56] | 1144 | Void TEncCavlc::codeTileMarkerFlag(TComSlice* pcSlice) |
---|
[2] | 1145 | { |
---|
[56] | 1146 | Bool bEntropySlice = (!pcSlice->isNextSlice()); |
---|
| 1147 | if (!bEntropySlice) |
---|
| 1148 | { |
---|
| 1149 | xWriteFlag (pcSlice->getTileMarkerFlag() ? 1 : 0 ); |
---|
| 1150 | } |
---|
[2] | 1151 | } |
---|
| 1152 | |
---|
[56] | 1153 | /** |
---|
| 1154 | - write wavefront substreams sizes for the slice header. |
---|
| 1155 | . |
---|
| 1156 | \param pcSlice Where we find the substream size information. |
---|
| 1157 | */ |
---|
| 1158 | Void TEncCavlc::codeTilesWPPEntryPoint( TComSlice* pSlice ) |
---|
[2] | 1159 | { |
---|
[56] | 1160 | Int tilesOrEntropyCodingSyncIdc = pSlice->getSPS()->getTilesOrEntropyCodingSyncIdc(); |
---|
[2] | 1161 | |
---|
[56] | 1162 | if ( tilesOrEntropyCodingSyncIdc == 0 ) |
---|
[2] | 1163 | { |
---|
[56] | 1164 | return; |
---|
[2] | 1165 | } |
---|
| 1166 | |
---|
[56] | 1167 | UInt numEntryPointOffsets = 0, offsetLenMinus1 = 0, maxOffset = 0; |
---|
| 1168 | UInt *entryPointOffset = NULL; |
---|
| 1169 | if (tilesOrEntropyCodingSyncIdc == 1) // tiles |
---|
[2] | 1170 | { |
---|
[56] | 1171 | numEntryPointOffsets = pSlice->getTileLocationCount(); |
---|
| 1172 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
| 1173 | for (Int idx=0; idx<pSlice->getTileLocationCount(); idx++) |
---|
[2] | 1174 | { |
---|
[56] | 1175 | if ( idx == 0 ) |
---|
[2] | 1176 | { |
---|
[56] | 1177 | entryPointOffset [ idx ] = pSlice->getTileLocation( 0 ); |
---|
[2] | 1178 | } |
---|
[56] | 1179 | else |
---|
[2] | 1180 | { |
---|
[56] | 1181 | entryPointOffset [ idx ] = pSlice->getTileLocation( idx ) - pSlice->getTileLocation( idx-1 ); |
---|
[2] | 1182 | } |
---|
| 1183 | |
---|
[56] | 1184 | if ( entryPointOffset[ idx ] > maxOffset ) |
---|
| 1185 | { |
---|
| 1186 | maxOffset = entryPointOffset[ idx ]; |
---|
| 1187 | } |
---|
[2] | 1188 | } |
---|
| 1189 | } |
---|
[56] | 1190 | else if (tilesOrEntropyCodingSyncIdc == 2) // wavefront |
---|
[2] | 1191 | { |
---|
[56] | 1192 | Int numZeroSubstreamsAtEndOfSlice = 0; |
---|
| 1193 | UInt* pSubstreamSizes = pSlice->getSubstreamSizes(); |
---|
| 1194 | // Find number of zero substreams at the end of slice |
---|
| 1195 | for (Int idx=pSlice->getPPS()->getNumSubstreams()-2; idx>=0; idx--) |
---|
[2] | 1196 | { |
---|
[56] | 1197 | if ( pSubstreamSizes[ idx ] == 0 ) |
---|
[2] | 1198 | { |
---|
[56] | 1199 | numZeroSubstreamsAtEndOfSlice++; |
---|
[2] | 1200 | } |
---|
[56] | 1201 | else |
---|
[2] | 1202 | { |
---|
[56] | 1203 | break; |
---|
[2] | 1204 | } |
---|
| 1205 | } |
---|
[56] | 1206 | numEntryPointOffsets = pSlice->getPPS()->getNumSubstreams() - 1 - numZeroSubstreamsAtEndOfSlice; |
---|
| 1207 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
| 1208 | for (Int idx=0; idx<numEntryPointOffsets; idx++) |
---|
[2] | 1209 | { |
---|
[56] | 1210 | entryPointOffset[ idx ] = ( pSubstreamSizes[ idx ] >> 3 ) ; |
---|
| 1211 | if ( entryPointOffset[ idx ] > maxOffset ) |
---|
[2] | 1212 | { |
---|
[56] | 1213 | maxOffset = entryPointOffset[ idx ]; |
---|
[2] | 1214 | } |
---|
| 1215 | } |
---|
[56] | 1216 | } |
---|
[2] | 1217 | |
---|
[56] | 1218 | 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] | 1219 | |
---|
[56] | 1220 | // Determine number of bits "offsetLenMinus1+1" required for entry point information |
---|
| 1221 | offsetLenMinus1 = 0; |
---|
| 1222 | while (1) |
---|
| 1223 | { |
---|
| 1224 | if (maxOffset >= (1 << offsetLenMinus1) ) |
---|
| 1225 | { |
---|
| 1226 | offsetLenMinus1++; |
---|
| 1227 | if ( offsetLenMinus1 > 32 ) |
---|
[2] | 1228 | { |
---|
[56] | 1229 | FATAL_ERROR_0("exceeded 32-bits", -1); |
---|
[2] | 1230 | } |
---|
| 1231 | } |
---|
[56] | 1232 | else |
---|
[2] | 1233 | { |
---|
[56] | 1234 | break; |
---|
[2] | 1235 | } |
---|
| 1236 | } |
---|
| 1237 | |
---|
[56] | 1238 | WRITE_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); |
---|
| 1239 | if (numEntryPointOffsets>0) |
---|
[2] | 1240 | { |
---|
[56] | 1241 | WRITE_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
[2] | 1242 | } |
---|
[56] | 1243 | |
---|
| 1244 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
[2] | 1245 | { |
---|
[56] | 1246 | if ( idx == 0 ) |
---|
| 1247 | { |
---|
| 1248 | // Adding sizes of NALU header and slice header information to entryPointOffset[ 0 ] |
---|
| 1249 | Int bitDistFromNALUHdrStart = m_pcBitIf->getNumberOfWrittenBits() + 16; |
---|
| 1250 | entryPointOffset[ idx ] += ( bitDistFromNALUHdrStart + numEntryPointOffsets*(offsetLenMinus1+1) ) >> 3; |
---|
| 1251 | } |
---|
| 1252 | WRITE_CODE(entryPointOffset[ idx ], offsetLenMinus1+1, "entry_point_offset"); |
---|
[2] | 1253 | } |
---|
| 1254 | |
---|
[56] | 1255 | delete [] entryPointOffset; |
---|
[2] | 1256 | } |
---|
| 1257 | |
---|
[56] | 1258 | Void TEncCavlc::codeTerminatingBit ( UInt uilsLast ) |
---|
[2] | 1259 | { |
---|
[56] | 1260 | } |
---|
[2] | 1261 | |
---|
[56] | 1262 | Void TEncCavlc::codeSliceFinish () |
---|
| 1263 | { |
---|
| 1264 | } |
---|
[2] | 1265 | |
---|
[292] | 1266 | #if H3D_IVMP |
---|
[56] | 1267 | Void TEncCavlc::codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Int iNum ) |
---|
[2] | 1268 | #else |
---|
[56] | 1269 | Void TEncCavlc::codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
[2] | 1270 | #endif |
---|
[56] | 1271 | { |
---|
| 1272 | assert(0); |
---|
| 1273 | } |
---|
[2] | 1274 | |
---|
[56] | 1275 | Void TEncCavlc::codePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1276 | { |
---|
| 1277 | assert(0); |
---|
| 1278 | } |
---|
[2] | 1279 | |
---|
[56] | 1280 | Void TEncCavlc::codePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1281 | { |
---|
| 1282 | assert(0); |
---|
| 1283 | } |
---|
[2] | 1284 | |
---|
[56] | 1285 | Void TEncCavlc::codeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1286 | { |
---|
| 1287 | assert(0); |
---|
| 1288 | } |
---|
[2] | 1289 | |
---|
[56] | 1290 | Void TEncCavlc::codeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1291 | { |
---|
| 1292 | assert(0); |
---|
| 1293 | } |
---|
[2] | 1294 | |
---|
[295] | 1295 | #if H3D_IVRP |
---|
[56] | 1296 | Void |
---|
| 1297 | TEncCavlc::codeResPredFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1298 | { |
---|
| 1299 | assert(0); |
---|
| 1300 | } |
---|
[2] | 1301 | #endif |
---|
| 1302 | |
---|
[56] | 1303 | Void TEncCavlc::codeAlfCtrlFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1304 | { |
---|
| 1305 | if (!m_bAlfCtrl) |
---|
| 1306 | { |
---|
| 1307 | return; |
---|
[2] | 1308 | } |
---|
[56] | 1309 | |
---|
| 1310 | if( pcCU->getDepth(uiAbsPartIdx) > m_uiMaxAlfCtrlDepth && !pcCU->isFirstAbsZorderIdxInDepth(uiAbsPartIdx, m_uiMaxAlfCtrlDepth)) |
---|
| 1311 | { |
---|
| 1312 | return; |
---|
| 1313 | } |
---|
| 1314 | |
---|
| 1315 | // get context function is here |
---|
| 1316 | UInt uiSymbol = pcCU->getAlfCtrlFlag( uiAbsPartIdx ) ? 1 : 0; |
---|
| 1317 | |
---|
| 1318 | xWriteFlag( uiSymbol ); |
---|
| 1319 | } |
---|
[2] | 1320 | |
---|
[56] | 1321 | Void TEncCavlc::codeApsExtensionFlag () |
---|
| 1322 | { |
---|
| 1323 | WRITE_FLAG(0, "aps_extension_flag"); |
---|
[2] | 1324 | } |
---|
| 1325 | |
---|
[56] | 1326 | Void TEncCavlc::codeAlfCtrlDepth() |
---|
| 1327 | { |
---|
| 1328 | if (!m_bAlfCtrl) |
---|
[2] | 1329 | { |
---|
[56] | 1330 | return; |
---|
[2] | 1331 | } |
---|
[56] | 1332 | |
---|
| 1333 | UInt uiDepth = m_uiMaxAlfCtrlDepth; |
---|
| 1334 | |
---|
| 1335 | xWriteUvlc(uiDepth); |
---|
| 1336 | } |
---|
[2] | 1337 | |
---|
[56] | 1338 | Void TEncCavlc::codeInterModeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiEncMode ) |
---|
| 1339 | { |
---|
| 1340 | assert(0); |
---|
| 1341 | } |
---|
[2] | 1342 | |
---|
[56] | 1343 | Void TEncCavlc::codeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1344 | { |
---|
| 1345 | assert(0); |
---|
| 1346 | } |
---|
[2] | 1347 | |
---|
[189] | 1348 | #if LGE_ILLUCOMP_B0045 |
---|
| 1349 | Void TEncCavlc::codeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1350 | { |
---|
| 1351 | assert(0); |
---|
| 1352 | } |
---|
| 1353 | #endif |
---|
| 1354 | |
---|
[56] | 1355 | Void TEncCavlc::codeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1356 | { |
---|
| 1357 | assert(0); |
---|
| 1358 | } |
---|
[2] | 1359 | |
---|
[56] | 1360 | Void TEncCavlc::codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) |
---|
| 1361 | { |
---|
| 1362 | assert(0); |
---|
| 1363 | } |
---|
[2] | 1364 | |
---|
[56] | 1365 | Void TEncCavlc::codeQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) |
---|
| 1366 | { |
---|
| 1367 | assert(0); |
---|
| 1368 | } |
---|
[2] | 1369 | |
---|
[56] | 1370 | Void TEncCavlc::codeQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1371 | { |
---|
| 1372 | assert(0); |
---|
| 1373 | } |
---|
[2] | 1374 | |
---|
[56] | 1375 | /** Code I_PCM information. |
---|
| 1376 | * \param pcCU pointer to CU |
---|
| 1377 | * \param uiAbsPartIdx CU index |
---|
| 1378 | * \param numIPCM the number of succesive IPCM blocks with the same size |
---|
| 1379 | * \param firstIPCMFlag |
---|
| 1380 | * \returns Void |
---|
| 1381 | */ |
---|
| 1382 | Void TEncCavlc::codeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, Int numIPCM, Bool firstIPCMFlag) |
---|
| 1383 | { |
---|
| 1384 | assert(0); |
---|
| 1385 | } |
---|
[2] | 1386 | |
---|
[56] | 1387 | Void TEncCavlc::codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1388 | { |
---|
| 1389 | assert(0); |
---|
| 1390 | } |
---|
[2] | 1391 | |
---|
[56] | 1392 | Void TEncCavlc::codeIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1393 | { |
---|
| 1394 | assert(0); |
---|
[2] | 1395 | } |
---|
| 1396 | |
---|
[56] | 1397 | Void TEncCavlc::codeInterDir( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
[2] | 1398 | { |
---|
[56] | 1399 | assert(0); |
---|
| 1400 | } |
---|
[2] | 1401 | |
---|
[56] | 1402 | Void TEncCavlc::codeRefFrmIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
| 1403 | { |
---|
| 1404 | assert(0); |
---|
[2] | 1405 | } |
---|
| 1406 | |
---|
[56] | 1407 | Void TEncCavlc::codeMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
[2] | 1408 | { |
---|
[56] | 1409 | assert(0); |
---|
[2] | 1410 | } |
---|
| 1411 | |
---|
[56] | 1412 | Void TEncCavlc::codeDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1413 | { |
---|
| 1414 | Int iDQp = pcCU->getQP( uiAbsPartIdx ) - pcCU->getRefQP( uiAbsPartIdx ); |
---|
| 1415 | |
---|
| 1416 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
| 1417 | iDQp = (iDQp + 78 + qpBdOffsetY + (qpBdOffsetY/2)) % (52 + qpBdOffsetY) - 26 - (qpBdOffsetY/2); |
---|
| 1418 | |
---|
| 1419 | xWriteSvlc( iDQp ); |
---|
| 1420 | |
---|
| 1421 | return; |
---|
| 1422 | } |
---|
| 1423 | |
---|
| 1424 | Void TEncCavlc::codeCoeffNxN ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) |
---|
| 1425 | { |
---|
| 1426 | assert(0); |
---|
| 1427 | } |
---|
| 1428 | |
---|
| 1429 | Void TEncCavlc::codeAlfFlag( UInt uiCode ) |
---|
| 1430 | { |
---|
| 1431 | xWriteFlag( uiCode ); |
---|
| 1432 | } |
---|
| 1433 | |
---|
[2] | 1434 | Void TEncCavlc::codeAlfCtrlFlag( UInt uiSymbol ) |
---|
| 1435 | { |
---|
| 1436 | xWriteFlag( uiSymbol ); |
---|
| 1437 | } |
---|
| 1438 | |
---|
| 1439 | Void TEncCavlc::codeAlfUvlc( UInt uiCode ) |
---|
| 1440 | { |
---|
| 1441 | xWriteUvlc( uiCode ); |
---|
| 1442 | } |
---|
| 1443 | |
---|
| 1444 | Void TEncCavlc::codeAlfSvlc( Int iCode ) |
---|
| 1445 | { |
---|
| 1446 | xWriteSvlc( iCode ); |
---|
| 1447 | } |
---|
[56] | 1448 | /** Code the fixed length code (smaller than one max value) in OSALF |
---|
| 1449 | * \param idx: coded value |
---|
| 1450 | * \param maxValue: max value |
---|
| 1451 | */ |
---|
| 1452 | Void TEncCavlc::codeAlfFixedLengthIdx( UInt idx, UInt maxValue) |
---|
[2] | 1453 | { |
---|
[56] | 1454 | UInt length = 0; |
---|
| 1455 | assert(idx<=maxValue); |
---|
[2] | 1456 | |
---|
[56] | 1457 | UInt temp = maxValue; |
---|
| 1458 | for(UInt i=0; i<32; i++) |
---|
| 1459 | { |
---|
| 1460 | if(temp&0x1) |
---|
| 1461 | { |
---|
| 1462 | length = i+1; |
---|
| 1463 | } |
---|
| 1464 | temp = (temp >> 1); |
---|
| 1465 | } |
---|
| 1466 | |
---|
| 1467 | if(length) |
---|
| 1468 | { |
---|
| 1469 | xWriteCode( idx, length ); |
---|
| 1470 | } |
---|
| 1471 | } |
---|
| 1472 | |
---|
| 1473 | Void TEncCavlc::codeSaoFlag( UInt uiCode ) |
---|
| 1474 | { |
---|
[2] | 1475 | xWriteFlag( uiCode ); |
---|
| 1476 | } |
---|
| 1477 | |
---|
[56] | 1478 | Void TEncCavlc::codeSaoUvlc( UInt uiCode ) |
---|
[2] | 1479 | { |
---|
| 1480 | xWriteUvlc( uiCode ); |
---|
| 1481 | } |
---|
| 1482 | |
---|
[56] | 1483 | Void TEncCavlc::codeSaoSvlc( Int iCode ) |
---|
[2] | 1484 | { |
---|
| 1485 | xWriteSvlc( iCode ); |
---|
| 1486 | } |
---|
[56] | 1487 | /** Code SAO run. |
---|
| 1488 | * \param uiCode |
---|
| 1489 | * \param maxValue |
---|
| 1490 | */ |
---|
| 1491 | Void TEncCavlc::codeSaoRun( UInt uiCode, UInt maxValue) |
---|
| 1492 | { |
---|
| 1493 | UInt uiLength = 0; |
---|
| 1494 | if (!maxValue) |
---|
| 1495 | { |
---|
| 1496 | return; |
---|
| 1497 | } |
---|
| 1498 | assert(uiCode<=maxValue); |
---|
[2] | 1499 | |
---|
[56] | 1500 | for(UInt i=0; i<32; i++) |
---|
| 1501 | { |
---|
| 1502 | if(maxValue&0x1) |
---|
| 1503 | { |
---|
| 1504 | uiLength = i+1; |
---|
| 1505 | } |
---|
| 1506 | maxValue = (maxValue >> 1); |
---|
| 1507 | } |
---|
| 1508 | WRITE_CODE( uiCode, uiLength, "sao_run_diff"); |
---|
| 1509 | } |
---|
[2] | 1510 | |
---|
[56] | 1511 | Void TEncCavlc::estBit( estBitsSbacStruct* pcEstBitsCabac, Int width, Int height, TextType eTType ) |
---|
[2] | 1512 | { |
---|
| 1513 | // printf("error : no VLC mode support in this version\n"); |
---|
| 1514 | return; |
---|
| 1515 | } |
---|
| 1516 | |
---|
| 1517 | // ==================================================================================================================== |
---|
| 1518 | // Protected member functions |
---|
| 1519 | // ==================================================================================================================== |
---|
| 1520 | |
---|
| 1521 | Void TEncCavlc::xWriteCode ( UInt uiCode, UInt uiLength ) |
---|
| 1522 | { |
---|
| 1523 | assert ( uiLength > 0 ); |
---|
| 1524 | m_pcBitIf->write( uiCode, uiLength ); |
---|
| 1525 | } |
---|
| 1526 | |
---|
| 1527 | Void TEncCavlc::xWriteUvlc ( UInt uiCode ) |
---|
| 1528 | { |
---|
| 1529 | UInt uiLength = 1; |
---|
| 1530 | UInt uiTemp = ++uiCode; |
---|
[56] | 1531 | |
---|
[2] | 1532 | assert ( uiTemp ); |
---|
[56] | 1533 | |
---|
[2] | 1534 | while( 1 != uiTemp ) |
---|
| 1535 | { |
---|
| 1536 | uiTemp >>= 1; |
---|
| 1537 | uiLength += 2; |
---|
| 1538 | } |
---|
[56] | 1539 | |
---|
| 1540 | //m_pcBitIf->write( uiCode, uiLength ); |
---|
| 1541 | // Take care of cases where uiLength > 32 |
---|
| 1542 | m_pcBitIf->write( 0, uiLength >> 1); |
---|
| 1543 | m_pcBitIf->write( uiCode, (uiLength+1) >> 1); |
---|
[2] | 1544 | } |
---|
| 1545 | |
---|
| 1546 | Void TEncCavlc::xWriteSvlc ( Int iCode ) |
---|
| 1547 | { |
---|
| 1548 | UInt uiCode; |
---|
[56] | 1549 | |
---|
[2] | 1550 | uiCode = xConvertToUInt( iCode ); |
---|
| 1551 | xWriteUvlc( uiCode ); |
---|
| 1552 | } |
---|
| 1553 | |
---|
| 1554 | Void TEncCavlc::xWriteFlag( UInt uiCode ) |
---|
| 1555 | { |
---|
| 1556 | m_pcBitIf->write( uiCode, 1 ); |
---|
| 1557 | } |
---|
| 1558 | |
---|
[56] | 1559 | /** Write PCM alignment bits. |
---|
| 1560 | * \returns Void |
---|
| 1561 | */ |
---|
| 1562 | Void TEncCavlc::xWritePCMAlignZero () |
---|
[2] | 1563 | { |
---|
[56] | 1564 | m_pcBitIf->writeAlignZero(); |
---|
[2] | 1565 | } |
---|
| 1566 | |
---|
| 1567 | Void TEncCavlc::xWriteUnaryMaxSymbol( UInt uiSymbol, UInt uiMaxSymbol ) |
---|
| 1568 | { |
---|
| 1569 | if (uiMaxSymbol == 0) |
---|
| 1570 | { |
---|
| 1571 | return; |
---|
| 1572 | } |
---|
| 1573 | xWriteFlag( uiSymbol ? 1 : 0 ); |
---|
| 1574 | if ( uiSymbol == 0 ) |
---|
| 1575 | { |
---|
| 1576 | return; |
---|
| 1577 | } |
---|
[56] | 1578 | |
---|
[2] | 1579 | Bool bCodeLast = ( uiMaxSymbol > uiSymbol ); |
---|
[56] | 1580 | |
---|
[2] | 1581 | while( --uiSymbol ) |
---|
| 1582 | { |
---|
| 1583 | xWriteFlag( 1 ); |
---|
| 1584 | } |
---|
| 1585 | if( bCodeLast ) |
---|
| 1586 | { |
---|
| 1587 | xWriteFlag( 0 ); |
---|
| 1588 | } |
---|
| 1589 | return; |
---|
| 1590 | } |
---|
| 1591 | |
---|
| 1592 | Void TEncCavlc::xWriteExGolombLevel( UInt uiSymbol ) |
---|
| 1593 | { |
---|
| 1594 | if( uiSymbol ) |
---|
| 1595 | { |
---|
| 1596 | xWriteFlag( 1 ); |
---|
| 1597 | UInt uiCount = 0; |
---|
| 1598 | Bool bNoExGo = (uiSymbol < 13); |
---|
[56] | 1599 | |
---|
[2] | 1600 | while( --uiSymbol && ++uiCount < 13 ) |
---|
| 1601 | { |
---|
| 1602 | xWriteFlag( 1 ); |
---|
| 1603 | } |
---|
| 1604 | if( bNoExGo ) |
---|
| 1605 | { |
---|
| 1606 | xWriteFlag( 0 ); |
---|
| 1607 | } |
---|
| 1608 | else |
---|
| 1609 | { |
---|
| 1610 | xWriteEpExGolomb( uiSymbol, 0 ); |
---|
| 1611 | } |
---|
| 1612 | } |
---|
| 1613 | else |
---|
| 1614 | { |
---|
| 1615 | xWriteFlag( 0 ); |
---|
| 1616 | } |
---|
| 1617 | return; |
---|
| 1618 | } |
---|
| 1619 | |
---|
| 1620 | Void TEncCavlc::xWriteEpExGolomb( UInt uiSymbol, UInt uiCount ) |
---|
| 1621 | { |
---|
| 1622 | while( uiSymbol >= (UInt)(1<<uiCount) ) |
---|
| 1623 | { |
---|
| 1624 | xWriteFlag( 1 ); |
---|
| 1625 | uiSymbol -= 1<<uiCount; |
---|
| 1626 | uiCount ++; |
---|
| 1627 | } |
---|
| 1628 | xWriteFlag( 0 ); |
---|
| 1629 | while( uiCount-- ) |
---|
| 1630 | { |
---|
| 1631 | xWriteFlag( (uiSymbol>>uiCount) & 1 ); |
---|
| 1632 | } |
---|
| 1633 | return; |
---|
| 1634 | } |
---|
| 1635 | |
---|
[56] | 1636 | /** code explicit wp tables |
---|
| 1637 | * \param TComSlice* pcSlice |
---|
| 1638 | * \returns Void |
---|
[2] | 1639 | */ |
---|
[56] | 1640 | Void TEncCavlc::xCodePredWeightTable( TComSlice* pcSlice ) |
---|
[2] | 1641 | { |
---|
[56] | 1642 | wpScalingParam *wp; |
---|
| 1643 | Bool bChroma = true; // color always present in HEVC ? |
---|
| 1644 | Int iNbRef = (pcSlice->getSliceType() == B_SLICE ) ? (2) : (1); |
---|
| 1645 | Bool bDenomCoded = false; |
---|
[2] | 1646 | |
---|
[56] | 1647 | UInt uiMode = 0; |
---|
| 1648 | if ( (pcSlice->getSliceType()==P_SLICE && pcSlice->getPPS()->getUseWP()) || (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPredIdc()==1 && pcSlice->getRefPicListCombinationFlag()==0 ) ) |
---|
| 1649 | uiMode = 1; // explicit |
---|
| 1650 | else if ( pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPredIdc()==2 ) |
---|
| 1651 | uiMode = 2; // implicit (does not use this mode in this syntax) |
---|
| 1652 | if (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPredIdc()==1 && pcSlice->getRefPicListCombinationFlag()) |
---|
| 1653 | uiMode = 3; // combined explicit |
---|
| 1654 | if(uiMode == 1) |
---|
[2] | 1655 | { |
---|
[56] | 1656 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
[2] | 1657 | { |
---|
[56] | 1658 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
| 1659 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
[2] | 1660 | { |
---|
[56] | 1661 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 1662 | if ( !bDenomCoded ) |
---|
[2] | 1663 | { |
---|
[56] | 1664 | Int iDeltaDenom; |
---|
| 1665 | WRITE_UVLC( wp[0].uiLog2WeightDenom, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
[2] | 1666 | |
---|
[56] | 1667 | if( bChroma ) |
---|
[2] | 1668 | { |
---|
[56] | 1669 | iDeltaDenom = (wp[1].uiLog2WeightDenom - wp[0].uiLog2WeightDenom); |
---|
| 1670 | WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
[2] | 1671 | } |
---|
[56] | 1672 | bDenomCoded = true; |
---|
| 1673 | } |
---|
[2] | 1674 | |
---|
[56] | 1675 | WRITE_FLAG( wp[0].bPresentFlag, "luma_weight_lX_flag" ); // u(1): luma_weight_lX_flag |
---|
[2] | 1676 | |
---|
[56] | 1677 | if ( wp[0].bPresentFlag ) |
---|
| 1678 | { |
---|
| 1679 | Int iDeltaWeight = (wp[0].iWeight - (1<<wp[0].uiLog2WeightDenom)); |
---|
| 1680 | WRITE_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_lX |
---|
| 1681 | WRITE_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_lX |
---|
| 1682 | } |
---|
[2] | 1683 | |
---|
[56] | 1684 | if ( bChroma ) |
---|
| 1685 | { |
---|
| 1686 | WRITE_FLAG( wp[1].bPresentFlag, "chroma_weight_lX_flag" ); // u(1): chroma_weight_lX_flag |
---|
[2] | 1687 | |
---|
[56] | 1688 | if ( wp[1].bPresentFlag ) |
---|
[2] | 1689 | { |
---|
[56] | 1690 | for ( Int j=1 ; j<3 ; j++ ) |
---|
[2] | 1691 | { |
---|
[56] | 1692 | Int iDeltaWeight = (wp[j].iWeight - (1<<wp[1].uiLog2WeightDenom)); |
---|
| 1693 | WRITE_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): delta_chroma_weight_lX |
---|
| 1694 | |
---|
| 1695 | Int iDeltaChroma = (wp[j].iOffset + ( ( (g_uiIBDI_MAX>>1)*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) - (g_uiIBDI_MAX>>1)); |
---|
| 1696 | WRITE_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_lX |
---|
[2] | 1697 | } |
---|
| 1698 | } |
---|
| 1699 | } |
---|
| 1700 | } |
---|
| 1701 | } |
---|
| 1702 | } |
---|
[56] | 1703 | else if (uiMode == 3) |
---|
[2] | 1704 | { |
---|
[56] | 1705 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(REF_PIC_LIST_C) ; iRefIdx++ ) |
---|
| 1706 | { |
---|
| 1707 | RefPicList eRefPicList = (RefPicList)pcSlice->getListIdFromIdxOfLC(iRefIdx); |
---|
| 1708 | Int iCombRefIdx = pcSlice->getRefIdxFromIdxOfLC(iRefIdx); |
---|
[2] | 1709 | |
---|
[56] | 1710 | pcSlice->getWpScaling(eRefPicList, iCombRefIdx, wp); |
---|
| 1711 | if ( !bDenomCoded ) |
---|
[2] | 1712 | { |
---|
[56] | 1713 | Int iDeltaDenom; |
---|
| 1714 | WRITE_UVLC( wp[0].uiLog2WeightDenom, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
| 1715 | |
---|
| 1716 | if( bChroma ) |
---|
| 1717 | { |
---|
| 1718 | iDeltaDenom = (wp[1].uiLog2WeightDenom - wp[0].uiLog2WeightDenom); |
---|
| 1719 | WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
| 1720 | } |
---|
| 1721 | bDenomCoded = true; |
---|
[2] | 1722 | } |
---|
| 1723 | |
---|
[56] | 1724 | WRITE_FLAG( wp[0].bPresentFlag, "luma_weight_lc_flag" ); // u(1): luma_weight_lc_flag |
---|
[2] | 1725 | |
---|
[56] | 1726 | if ( wp[0].bPresentFlag ) |
---|
| 1727 | { |
---|
| 1728 | Int iDeltaWeight = (wp[0].iWeight - (1<<wp[0].uiLog2WeightDenom)); |
---|
| 1729 | WRITE_SVLC( iDeltaWeight, "delta_luma_weight_lc" ); // se(v): delta_luma_weight_lc |
---|
| 1730 | WRITE_SVLC( wp[0].iOffset, "luma_offset_lc" ); // se(v): luma_offset_lc |
---|
| 1731 | } |
---|
| 1732 | if ( bChroma ) |
---|
| 1733 | { |
---|
| 1734 | WRITE_FLAG( wp[1].bPresentFlag, "chroma_weight_lc_flag" ); // u(1): luma_weight_lc_flag |
---|
[2] | 1735 | |
---|
[56] | 1736 | if ( wp[1].bPresentFlag ) |
---|
| 1737 | { |
---|
| 1738 | for ( Int j=1 ; j<3 ; j++ ) |
---|
| 1739 | { |
---|
| 1740 | Int iDeltaWeight = (wp[j].iWeight - (1<<wp[1].uiLog2WeightDenom)); |
---|
| 1741 | WRITE_SVLC( iDeltaWeight, "delta_chroma_weight_lc" ); // se(v): delta_chroma_weight_lc |
---|
[2] | 1742 | |
---|
[56] | 1743 | Int iDeltaChroma = (wp[j].iOffset + ( ( (g_uiIBDI_MAX>>1)*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) - (g_uiIBDI_MAX>>1)); |
---|
| 1744 | WRITE_SVLC( iDeltaChroma, "delta_chroma_offset_lc" ); // se(v): delta_chroma_offset_lc |
---|
| 1745 | } |
---|
| 1746 | } |
---|
| 1747 | } |
---|
[2] | 1748 | } |
---|
| 1749 | } |
---|
[56] | 1750 | } |
---|
[2] | 1751 | |
---|
[56] | 1752 | /** code quantization matrix |
---|
| 1753 | * \param scalingList quantization matrix information |
---|
| 1754 | */ |
---|
| 1755 | Void TEncCavlc::codeScalingList( TComScalingList* scalingList ) |
---|
| 1756 | { |
---|
| 1757 | UInt listId,sizeId; |
---|
| 1758 | Bool scalingListPredModeFlag; |
---|
[2] | 1759 | |
---|
[56] | 1760 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 1761 | Int startBit; |
---|
| 1762 | Int startTotalBit; |
---|
| 1763 | startBit = m_pcBitIf->getNumberOfWrittenBits(); |
---|
| 1764 | startTotalBit = m_pcBitIf->getNumberOfWrittenBits(); |
---|
[2] | 1765 | #endif |
---|
| 1766 | |
---|
[56] | 1767 | WRITE_FLAG( scalingList->getScalingListPresentFlag (), "scaling_list_present_flag" ); |
---|
| 1768 | |
---|
| 1769 | if(scalingList->getScalingListPresentFlag () == false) |
---|
[2] | 1770 | { |
---|
[56] | 1771 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 1772 | printf("Header Bit %d\n",m_pcBitIf->getNumberOfWrittenBits()-startBit); |
---|
[2] | 1773 | #endif |
---|
[56] | 1774 | //for each size |
---|
| 1775 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
[2] | 1776 | { |
---|
[56] | 1777 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
[2] | 1778 | { |
---|
[56] | 1779 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 1780 | startBit = m_pcBitIf->getNumberOfWrittenBits(); |
---|
[2] | 1781 | #endif |
---|
[56] | 1782 | scalingListPredModeFlag = scalingList->checkPredMode( sizeId, listId ); |
---|
| 1783 | WRITE_FLAG( scalingListPredModeFlag, "scaling_list_pred_mode_flag" ); |
---|
| 1784 | if(!scalingListPredModeFlag)// Copy Mode |
---|
[2] | 1785 | { |
---|
[56] | 1786 | WRITE_UVLC( (Int)listId - (Int)scalingList->getRefMatrixId (sizeId,listId) - 1, "scaling_list_pred_matrix_id_delta"); |
---|
[2] | 1787 | } |
---|
[56] | 1788 | else// DPCM Mode |
---|
[2] | 1789 | { |
---|
[56] | 1790 | xCodeScalingList(scalingList, sizeId, listId); |
---|
[2] | 1791 | } |
---|
[56] | 1792 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 1793 | printf("Matrix [%d][%d] Bit %d\n",sizeId,listId,m_pcBitIf->getNumberOfWrittenBits() - startBit); |
---|
[2] | 1794 | #endif |
---|
| 1795 | } |
---|
| 1796 | } |
---|
| 1797 | } |
---|
[56] | 1798 | #if SCALING_LIST_OUTPUT_RESULT |
---|
| 1799 | else |
---|
[2] | 1800 | { |
---|
[56] | 1801 | printf("Header Bit %d\n",m_pcBitIf->getNumberOfWrittenBits()-startTotalBit); |
---|
[2] | 1802 | } |
---|
[56] | 1803 | printf("Total Bit %d\n",m_pcBitIf->getNumberOfWrittenBits()-startTotalBit); |
---|
| 1804 | #endif |
---|
[2] | 1805 | return; |
---|
| 1806 | } |
---|
[56] | 1807 | /** code DPCM |
---|
| 1808 | * \param scalingList quantization matrix information |
---|
| 1809 | * \param sizeIdc size index |
---|
| 1810 | * \param listIdc list index |
---|
| 1811 | */ |
---|
| 1812 | Void TEncCavlc::xCodeScalingList(TComScalingList* scalingList, UInt sizeId, UInt listId) |
---|
[2] | 1813 | { |
---|
[56] | 1814 | Int coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
| 1815 | UInt* scan = g_auiFrameScanXY [ (sizeId == 0)? 1 : 2]; |
---|
| 1816 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
| 1817 | Int data; |
---|
| 1818 | Int *src = scalingList->getScalingListAddress(sizeId, listId); |
---|
| 1819 | if(sizeId > SCALING_LIST_8x8 && scalingList->getUseDefaultScalingMatrixFlag(sizeId,listId)) |
---|
[2] | 1820 | { |
---|
[56] | 1821 | WRITE_SVLC( -8, "scaling_list_dc_coef_minus8"); |
---|
[2] | 1822 | } |
---|
[56] | 1823 | else if(sizeId < SCALING_LIST_16x16 && scalingList->getUseDefaultScalingMatrixFlag(sizeId,listId)) |
---|
[2] | 1824 | { |
---|
[56] | 1825 | WRITE_SVLC( -8, "scaling_list_delta_coef"); |
---|
[2] | 1826 | } |
---|
[56] | 1827 | else |
---|
[2] | 1828 | { |
---|
[56] | 1829 | if( sizeId > SCALING_LIST_8x8 ) |
---|
[2] | 1830 | { |
---|
[56] | 1831 | WRITE_SVLC( scalingList->getScalingListDC(sizeId,listId) - 8, "scaling_list_dc_coef_minus8"); |
---|
[2] | 1832 | } |
---|
[56] | 1833 | for(Int i=0;i<coefNum;i++) |
---|
[2] | 1834 | { |
---|
[56] | 1835 | data = src[scan[i]] - nextCoef; |
---|
| 1836 | nextCoef = src[scan[i]]; |
---|
| 1837 | if(data > 127) |
---|
[2] | 1838 | { |
---|
[56] | 1839 | data = data - 256; |
---|
[2] | 1840 | } |
---|
[56] | 1841 | if(data < -128) |
---|
[2] | 1842 | { |
---|
[56] | 1843 | data = data + 256; |
---|
[2] | 1844 | } |
---|
| 1845 | |
---|
[56] | 1846 | WRITE_SVLC( data, "scaling_list_delta_coef"); |
---|
[2] | 1847 | } |
---|
| 1848 | } |
---|
| 1849 | } |
---|
[56] | 1850 | Bool TComScalingList::checkPredMode(UInt sizeId, UInt listId) |
---|
| 1851 | { |
---|
| 1852 | for(Int predListIdx = (Int)listId -1 ; predListIdx >= 0; predListIdx--) |
---|
| 1853 | { |
---|
| 1854 | if( !memcmp(getScalingListAddress(sizeId,listId),getScalingListAddress(sizeId, predListIdx),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
| 1855 | && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == getScalingListDC(sizeId,predListIdx)))) // check DC value |
---|
| 1856 | { |
---|
| 1857 | setRefMatrixId(sizeId, listId, predListIdx); |
---|
| 1858 | return false; |
---|
[2] | 1859 | } |
---|
| 1860 | } |
---|
[56] | 1861 | return true; |
---|
[2] | 1862 | } |
---|
[189] | 1863 | |
---|
| 1864 | #if RWTH_SDC_DLT_B0036 |
---|
| 1865 | Void TEncCavlc::codeSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1866 | { |
---|
| 1867 | assert(0); |
---|
| 1868 | } |
---|
| 1869 | |
---|
| 1870 | Void TEncCavlc::codeSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment ) |
---|
| 1871 | { |
---|
| 1872 | assert(0); |
---|
| 1873 | } |
---|
| 1874 | |
---|
| 1875 | Void TEncCavlc::codeSDCPredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 1876 | { |
---|
| 1877 | assert(0); |
---|
| 1878 | } |
---|
| 1879 | #endif |
---|
[56] | 1880 | //! \} |
---|